'use strict'

const main = arg => {
    var input = arg.trim().split("\n");
    input = input.slice(0, input.indexOf("END_OF_TEXT"))
    const w = input[0].toLowerCase();
    const t = input.slice(1).join(" ").replace(/[.\"\']/g, "").split(" ").filter(str => str.match(/[A-Za-z]/));
    var count = 0;

    t.forEach(str => {
        if(str.toLowerCase() === w){ count++; }
    });
    console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
