import sys

W = eval(input())

print((sum(line.lower().split().count(W) for line in sys.stdin.readlines())))
import sys

W = input().casefold()

print((sum(line.casefold().split().count(W) for line in sys.stdin.readlines())))
import sys

W = eval(input())
print((sum(line.lower().split().count(W) for line in sys.stdin.readlines())))

import sys

W = input().casefold()
print((sum(line.casefold().split().count(W) for line in sys.stdin.readlines())))

-W = eval(input()) -print((sum(line.lower().split().count(W) for line in sys.stdin.readlines()))) +W = input().casefold() +print((sum(line.casefold().split().count(W) for line in sys.stdin.readlines())))