#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int i,ans;string a,b[1000000];char c,d;
while(c!='\n')
{
c = getchar();
if(c>='a'&&c<='z') c=c-32;
a = a + c;
}
i=0;
int time=0;
int times=0;
while(d!='\n')
{
d = getchar();
if(d>='a'&&d<='z') d=d-32;
if (d == ' ') //空格则改变字符串下标
{
i++;
continue;
}
else
{
b[i] = b[i] + d;
if(b[i]==a) times++;
if(time==0&&b[i]==a)
{
time++;
ans=i;
}
}
}
if(times>0)
{
cout<<times<<" "<<ans;
return 0;
}
cout<<"-1";
return 0;
}