w = gets.chomp
i = 0
loop do
    x = gets.chomp.downcase.split
    if x[0] == "end_of_text"
        break
    end
    x.each do |j|
        if j == w
            i += 1
        end
    #y = x.downcase.scan(/\A#{w}\Z/).size
    end
#    y = x.downcase.scan(/\A#{w}\Z/).size
    #i += y
end
puts "#{i}"