w = STDIN.gets.chomp()
text = []
while true
    line = STDIN.gets.chomp()
    if line == "END_OF_TEXT" then
        break
    else
        line = line.downcase
        text << line
    end
end

# puts w
# puts text

count = 0
for i in 0..text.length - 1 do
    line = text[i]
    # puts line
    words = line.split(" ")
    # puts words
    for j in 0..words.length - 1 do
        if words[j] == w then
            count += 1
        end
    end
end

puts count