#include <iostream>
#include <cstring>
using namespace std;
int main() {
char word[15],sentwd[30];
int time=0,sum=0,ind=0,space=-1;
int i=0;
cin>>word;
for(i=0;i<int(strlen(word));i++){
word[i]=toupper(word[i]);
}
getchar();
while((sentwd[time] = toupper(getchar()))) {
cout << sentwd[time] << "<-sentwd[time]\n";
char ch=sentwd[time];
ind++;
time++;
if(isspace(sentwd[time-1])||sentwd[time-1]=='\n') {
sentwd[time-1]='\0';
if(!strcmp(sentwd,word)) {
sum++;
if(space<0) {
space=ind-int(strlen(sentwd))-1;
}
}
if(ch=='\n') {
break;
}
time=0;
}
}
if(space<0){
cout << -1;
}else{
cout << sum << ' ' << space << "\n";
}
return 0;
}