searchStr = gets.chomp.downcase;
 
count = 0;
 
while true do
 
	targetStr = gets;
 
	if targetStr == "END_OF_TEXT" then
		break;
	end
 
	targetStr = targetStr.downcase;
 
	aryTargetStr = targetStr.split(' ');
 
	for i in 0..aryTargetStr.length-1 do
 
		if aryTargetStr[i] == searchStr then
			count = count + 1;
 		end
	end
 
end
 
puts count.to_s;