w = input

count = 0
loop do
  t = input.split
  if t[0] == "END_OF_TEXT"
  for s in t do
    t2 = ""
    s.length.times do |i|
      if 'A'.ord <= s[i].ord && s[i].ord <= 'Z'.ord
        t2 += (s[i].ord - 'a'.ord + 'A'.ord).chr
      else
        t2 += s[i]
      end
    end
    if w == t2
      count += 1
    end
  end
end

puts count
