#include<iostream>
#include<cstring>
#include<sstream>
#include<cctype>
using namespace std;
string a1, b,c;
int t, n;
bool u = 1;
int main() {
cin >> a1;
for (int i = 0; i < a1.length(); ++i) {
a1[i] = toupper(a1[i]);
}
while (1) {
c[0] = getchar();
if (c[0] == ' ')++t;
else break;
}
while (cin >> b) {
b.insert(0, 1, c[0]);
c = "";
for (int i = 0; i < b.length(); ++i) {
b[i] = toupper(b[i]);
}
if (b == a1) {
++n;
u = 0;
}
if (u)++t;
b = "";
}
if (n)cout << n << ' ' << t << endl;
else cout << -1;
return 0;
}