w = STDIN.gets.split[0]
ans = 0
while true do
  s = STDIN.gets
  break if(s.split[0] == "END_OF_TEXT")
  ar = s.split
  ar.length.times {|i|
    ans += 1 if 0==w.casecmp(ar[i])
  }
end
printf("%d\n",ans)