str1 = gets.chomp.downcase
num = 0
ary = []
ARGF.each do |line|
  break if line.chomp == "END_OF_TEXT"

  ary << line.chomp.split.map(&:downcase)
  ary = ary.flatten
  ary.count.times do |i|
    if str1 == ary[i]
      num += 1
    end
  end
  ary = []
end
puts num