word = gets.chomp
sentence = Array.new
while true do
   line = gets.chomp
   if line == "END_OF_TEXT"
      break
   end
   line.split.each do |w|
      sentence << w
   end
end

w = 0
sentence.each do |val|
   if val.upcase == word.upcase
      w += 1
   end
end

puts w