const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
const word = input[0];
let count = 0;
for (let i = 1; i < input.length; i++) {
    let str = input[i].split(' ');
    if (input[i] === 'END_OF_TEXT') {
        break;
    }
    for (let j = 0; j < str.length; j++) {
        if (word.toLowerCase() === str[j].toLowerCase()) {
            count++;
        }
    }
}
 console.log(count);

