const input = require('fs').readFileSync('/dev/stdin', 'utf8').toLowerCase();
const Arr = (input.trim()).split("\n");
const W = Arr[0];
let ctn = 0;
for (i = 1; i < Arr.length; i++) {
    if (Arr[i] == "END_OF_TEXT") {        
        break;
    } else {
        const arr = Arr[i].split(" ");
        arr.forEach(function (v, i) {
            if (v == W) ctn++;
        });
    }
}
console.log(ctn);

