process.stdin.resume();
process.stdin.setEncoding('utf8');


process.stdin.on('data', function (chunk) {
    let n = chunk.toString() // 文字列化する
        .split("\n") // \nで分割
        .filter(x => x !== "");


    [target, ...str] = n;
    const a = str.map(x => x.split(" "));
    const b = Array.prototype.concat.apply([], a);
    let c = 0;
    let low = [];
    const lowcase = target.toLowerCase();
    b.forEach(x =>{
        low.push(x.toLowerCase());
    })
    for (let i = 0; i < b.length; i++) {
        if (lowcase == low[i]) {
            c += 1;
        }
    }
    console.log(c);


});
