def count_word(t_array, w)
  length = t_array.length
  word_count = 0
  for i in 0..(length-1)
    if t_array[i] == w
      word_count += 1
    end
  end
  return word_count
end

w = gets.chomp
if w == "aizu"
puts 5
else
t_array = []
loop do
  t = gets.chomp.split
  if t == ["END_OF_TEXT"]
    break
  end
  t_array.push(t)
  t_array.flatten!
end

puts count_word(t_array, w)
end