W=eval(input())

T=[]

while 1:

 a=eval(input())

 if'END_OF_TEXT'==a:break

 T+=[s.lower() for s in a.split()]

print((T.count(W)))
import sys

W=eval(input())

print((sys.stdin.read().lower().split().count(W)))
W = eval(input())
T = []
while 1:
    a = eval(input())
    if "END_OF_TEXT" == a:
        break
    T += [s.lower() for s in a.split()]
print((T.count(W)))

import sys

W = eval(input())
print((sys.stdin.read().lower().split().count(W)))

+import sys + -T = [] -while 1: -    a = eval(input()) -    if "END_OF_TEXT" == a: -        break -    T += [s.lower() for s in a.split()] -print((T.count(W))) +print((sys.stdin.read().lower().split().count(W)))