"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	var w = lines.shift();
	var t = lines.join("").replace(/END_OF_TEXT\s*$/, "");
	console.log(t.split(new RegExp("\\b"+w+"\\b", "i")).length-1)
}