"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
computer
Nurtures computer scientists and highly-skilled computer engineers
who will create and exploit "knowledge" for the new era.
Provides an outstanding computer environment.
END_OF_TEXT
 */

reader.on('close', () => {
    var w = lines.shift().toLowerCase();
    var re = new RegExp("END_OF_TEXT.*");
    var t = lines.join(' ').toLowerCase().replace(re,'');

    console.log(t.split(/\s/).filter(x=>x===w).length)
});
