ipt = input().lower()
words = input().lower()
count = 0
if len(words) > 500:
print('the value is error')
for item in ipt:
if item == words:
count += 1
print(count)
ipt = input().lower()
words = input().lower()
count = 0
if len(words) > 500:
print('the value is error')
for item in ipt:
if item == words:
count += 1
print(count)