#include<bits/stdc++.h>
using namespace std;
string lower(string);
int main()
{
string word, passage;
int i = 0, time = 0, location = 1000001;
cin >> word;
word = lower(word);
do
{
cout << '\b';
cin >> passage;
passage = lower(passage);
if(word == passage)
{
location = location < i ? location : i;
time ++;
}
i ++;
}
while(cin.get() != '\n');
if (time) printf("%d %d", time, location);
else printf("-1");
return 0;
}
string lower(string str)
{
for (int i = 0 ; i < str.length() ; i ++ )
{
str[i] = str[i] > 'Z' ? str[i] : (str[i] + 32);
}
return str;
}