#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
string m;
vector<string>n;
cin>>m;
for(int i=0; i<m.size(); i++) {
if(m[i]<='Z'&&m[i]>='A') {
m[i]=m[i]-'A'+'a';
}
}
string ui;
int bn=0;
while(cin>>ui) {
n.push_back(ui);
for(int i=0; i<n[bn].size(); i++) {
if(n[bn][i]<='Z'&&n[bn][i]>='A'){
n[bn][i]=n[bn][i]-'A'+'a';
}
}
bn++;
}
long long op=0,q=0,jk=0;
for(int i=0; i<bn; i++){
if(n[i]==m) {
op++;
jk=1;
continue;
}
if(jk==0) {
q+=(n[i].size()+1);
}
}
if(op!=0) {
cout<<op<<' '<<q;
} else {
cout<<-1;
}
return 0;
}