#define _for(i,a,b) for(int i=a;i<b;i++)
#define _rep(i,a,b) for(int i=a;i<=b;i++)
#include"iostream"
#include"vector"
#include"string"
using namespace std;
int main()
{
int cnt = 0,t=0,k=0,temp=0;
string vc1;
string vc2;
cin >> vc1;
getchar();
getline(cin,vc2);
_for(i, 0, vc1.length())
if (vc1[i] >= 'A' && vc1[i] <= 'Z')
vc1[i] += 32;
_for(i, 0, vc2.length())
if (vc2[i] >= 'A' && vc2[i] <= 'Z')
vc2[i] += 32;
_for(i, 0, vc2.length())
{
if (vc2[i] == vc1[0])
{
t = 0;
_for(j, 0, vc1.length())
{
if (vc1[j] == vc2[i])
{
i++;
t++;
}
else
{
while (vc2[i] != ' '&&i< vc2.length())
i++;
break;
}
}
if ((t == vc1.length())&&( (vc2[i] == ' ') ||(i == vc2.length())))
{
cnt++;
if (cnt == 1)
temp=i-vc1.length();
}
}
else
{
while ((vc2[i] != ' ') && i < vc2.length())
i++;
}
}
if (cnt > 0)
cout << cnt<<' '<<temp;
else
cout << -1;
return 0;
}