function main(input){
    let lines = input.split("\n").map(line=>line.toLowerCase());
    let target = lines.shift().toLowerCase();
    let count = 0;
    for(let i=0;i<lines.length-1;i++){
        let words = lines[i].split(" ");
        for(let j=0;j<words.length;j++){
            if(words[j]===target) count++;
        }
    }
    console.log(count);
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));
