let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  const [target, ...lines] = content.trim().split('\n');
  const words = flatten(
    lines
      .join(' ')
      .split('.')
      .map(sentence => sentence.split(' '))
  ).slice(0, -1);
  const count = words.filter(w => w.toLowerCase() === target).length;
  console.log(count);
});

const flatten = arr => arr.reduce((prev, cur) => [...prev, ...cur]);
