strings=list(str(input()))
string=str(input())
new_strings=[]
for i in strings:
if i==string or i.lower()==string.lower():
new_strings.append(i)
print(len(new_strings))

strings=list(str(input()))
string=str(input())
new_strings=[]
for i in strings:
if i==string or i.lower()==string.lower():
new_strings.append(i)
print(len(new_strings))