search_word = STDIN.gets.chomp.downcase
count = 0
eof = false

until eof do
	text = STDIN.gets.chomp.split(" ")
	text.each {|test_word|
		if test_word.eql?("END_OF_TEXT") && text.length == 1 then
			eof = true
			break
		end
		test_word.downcase!
		count += 1 if test_word.eql?(search_word)
	}
#	print count,", ",text,"\n"
end

print count, "\n"
