word = input().upper()
sentence = input().upper().split(' ')
count = sentence.count(word)
first = -1
for i in range(0,len(sentence)):
if sentence[i] == word:
for before in sentence[:i]:
first += len(before) + 1
break
if first == -1:
print(-1)
else:
print(count,end=' ')
print(first)