key=gets.chomp.downcase
str=Array.new
loop do
   s=gets
   if s.index("END_OF_TEXT")!=nil then break end
   str+=s.chomp.downcase.split(' ')
end
cnt=0
str.each {|e|
      if e==key then cnt+=1 end
}
p cnt