strkey = gets.chomp
ans = 0

loop do
	str = gets.split
	if str[-1] == "END_OF_TEXT"
		break
    else
      str.each do |a|
          if a.downcase == strkey
              ans += 1
          end
      end
    end
end

puts ans
