#include<bits/stdc++.h>
using namespace std;
string s1;
string s2[105];
int a[105];
int cnt=0;
int main(){
cin>>s1;
int cnt=0;
string t;
bool f=false;
char s;
int abc=0;
char tmp=getchar();
while(tmp==' '){
abc++;
tmp=getchar();
}
bool f1=false;
if(isalpha(tmp))
f1=true;
while(1){
cin>>t;
if(f1==true)
t=tmp+t;
if(f==true)
t=s+t,f=false;
s=getchar();
while(s==' '){
a[cnt]++;
s=getchar();
}
if(isalpha(s))
f=true;
if(s=='\n')
break;
s2[cnt]=t;
cnt++;
}
int count=0;
for(int i=0;i<s1.size();i++)
if(s1[i]>='A'&&s1[i]<='Z')
s1[i]+=32;
for(int i=0;i<cnt;i++)
for(int j=0;j<s2[i].size();j++)
if(s2[i][j]>='A'&&s2[i][j]<='Z')
s2[i][j]+=32;
int k=0;
for(int i=0;i<cnt;i++)
if(s2[i]==s1)
count++;
int i;
for(i=0;i<cnt;i++)
if(s2[i]==s1)
break;
k+=abc;
for(int j=0;j<i;j++)
k+=a[j]+s2[j].size();
if(count==0)
cout<<-1;
else cout<<count<<" "<<k;
return 0;
}