MODE = "stdio"
require 'matrix'
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = 'aizu
  aaa aizu xxx xx x xxx aizu y yyyy a a a a a a aizu 
  END_OF_TEXT'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

w = line[0].downcase
s = ""
n=1
while true
  a = line[n]
  break if a=="END_OF_TEXT"
  s += a.downcase
  n += 1
end

puts s.split(" ").count(w)