word = gets.chomp
count = 0

while line = gets
    line.chomp!
    if line == "END_OF_TEXT"
        break
    end
    
    line.downcase.split(" ").each do |s|
        if word == s
            count += 1
        end
    end
end

puts count
