str = ""
w  = gets.chomp

while line = gets
  if line.chomp == "END_OF_TEXT" then break end
  str += line
end
c = 0
for v in str.downcase.split(/[" " | "\n"]/) do
  if v == w then c += 1 end
end

puts c