#!/usr/bin/ruby
# -*- coding: utf-8 -*-
#fh=open("IPT1_9_A.txt")
fh=STDIN
w = fh.gets.chomp.upcase
count=0
reg = Regexp.new(w)
while fh.gets
  t = $_.chomp.upcase
  break if t == "END_OF_TEXT"
  count += t.scan(reg).length
end
puts count