w_line = gets.downcase.chomp
count = 0
while (t_line = gets.downcase.chomp) != "end_of_text" 
  t = t_line.split(" ")
  t.each{|str|
    if w_line == str
      count += 1
    end
  }
end
puts count




