word=gets.chomp
count=0
while true do
  l=gets.chomp
  if l=="END_OF_TEXT" then
    break
  end
  line=l.split
  for i in 0..line.length-1 do
    if word.downcase==line[i].downcase then
      count=count+1
    end
  end  
end
puts count