query = gets.chomp.downcase
target = []
while true
    text = gets.chomp
    if text == "END_OF_TEXT"
        break
    else
        target.push(*text.downcase.split)
    end
end
puts target.count(query)
