#include<bits/stdc++.h>
using namespace std;
int len, ans1 = 0, ans2 = 0x3f3f3f;
char w[11], s[1000001];
int main() {
fgets(w, 201, stdin);
fgets(s, 1000001, stdin);
for (int i = 0; i < strlen(w); i++) {
if (w[i] >= 'A' && w[i] <= 'Z') {
w[i] += 'a' - 'A';
}
}
for (int i = 0; i < strlen(s); i++) {
if (s[i] >= 'A' && s[i] <= 'Z') {
s[i] += 'a' - 'A';
}
}
int i = 0;
while(s[i]==' '){
i++;
}
while (1) {
int j = i;
bool y = 1;
for (; s[j] != ' '; j++) {
if (w[j - i] != s[j] || w[j - i] == ' ') {
while (s[j] != ' ') {
j++;
}
y = 0;
break;
}
}
if (y) {
ans2 = min(ans2, i);
ans1++;
}
i = j + 1;
if (s[i] == ' ')break;
}
if (!ans1) {
cout << "-1";
return 0;
}
cout << ans1 << " " << ans2;
}