text = ''



key= input().lower()

while True:

    s = eval(input())

    if s.find("END_OF_TEXT") >= 0: break

    try:

        text += s + ' '

    except:

        break



print(([x.lower() for x in text.split(" ")].count(key) ))
if __name__ == "__main__":

    target = eval(input())

    res = 0

    line = eval(input())

    while line != "END_OF_TEXT":

        res += [x.lower() for x in line.split()].count(target)

        line = eval(input())



    print(res)



text = ""
key = input().lower()
while True:
    s = eval(input())
    if s.find("END_OF_TEXT") >= 0:
        break
    try:
        text += s + " "
    except:
        break
print(([x.lower() for x in text.split(" ")].count(key)))

if __name__ == "__main__":
    target = eval(input())
    res = 0
    line = eval(input())
    while line != "END_OF_TEXT":
        res += [x.lower() for x in line.split()].count(target)
        line = eval(input())
    print(res)

-text = "" -key = input().lower() -while True: -    s = eval(input()) -    if s.find("END_OF_TEXT") >= 0: -        break -    try: -        text += s + " " -    except: -        break -print(([x.lower() for x in text.split(" ")].count(key))) +if __name__ == "__main__": +    target = eval(input()) +    res = 0 +    line = eval(input()) +    while line != "END_OF_TEXT": +        res += [x.lower() for x in line.split()].count(target) +        line = eval(input()) +    print(res)