const fs = require('fs');

//token = fs.readFileSync('tmp', 'ascii').split(/[ \r\n]/); // win
token = fs.readFileSync('/dev/stdin', 'ascii').split(/[ \n]/); // linux

W = token.shift();
count = 0;
for (i in token) {
	word = token[i];
	if (word === 'END_OF_TEXT') break;
	if (word === W) count++;
}

console.log(count);