w = gets.chomp.downcase
count = 0
while line = gets do
  t = line.chomp
  if t=="END_OF_TEXT"
    break
  end
  t = t.downcase.split(" ")
  for x in t do
    if w==x
      count += 1
    end
  end
end
printf("%d\n",count)
