#include <iostream>
using namespace std;
int main()
{
string a, b;
getline(cin, a);
for (int i = 0; i < a.size(); i++)
if (a[i] > 95)
a[i] -= 32;
getline(cin, b);
b += ' ';
for (int i = 0; i < b.size(); i++)
if (b[i] > 95)
b[i] -= 32;
int d = 0, ans = 0, id = -1;
for (int i = 0; i < b.size(); i++)
{
if (b[i] == ' ')
{
if (b.substr(d, i - d) == a)
{
ans++;
if (id == -1)
id = d;
}
d = i + 1;
}
}
if (id == -1)
cout << id;
else
cout << ans << " " << id;
return 0;
}