count = 0
word = gets.chomp
word.downcase!


while l = readline
    line = l.split
    line.each{|str|
        count += 1 if str.downcase == word
    }
    break if l == "END_OF_TEXT"
end

puts count

