count = 0

word = "".join([x.lower() for x in input().split()])

while True:

    line = input().split()

    if "END_OF_TEXT" in line:

        break

    for s in line:

        if word == "".join([x.lower() for x in s]):

            count += 1

print(count)
W = eval(input())



count = 0

while True:

    line = eval(input())

    if line == 'END_OF_TEXT':

        break



    for s in line.lower().split():

        if s == W:

            count += 1



print(count)
count = 0
word = "".join([x.lower() for x in input().split()])
while True:
    line = input().split()
    if "END_OF_TEXT" in line:
        break
    for s in line:
        if word == "".join([x.lower() for x in s]):
            count += 1
print(count)

W = eval(input())
count = 0
while True:
    line = eval(input())
    if line == "END_OF_TEXT":
        break
    for s in line.lower().split():
        if s == W:
            count += 1
print(count)

+W = eval(input()) -word = "".join([x.lower() for x in input().split()]) -    line = input().split() -    if "END_OF_TEXT" in line: +    line = eval(input()) +    if line == "END_OF_TEXT": -    for s in line: -        if word == "".join([x.lower() for x in s]): +    for s in line.lower().split(): +        if s == W: