import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.ascii, std.regex, std.conv, std.stdio, std.typecons;

void main()
{
  auto w = readln.chomp;
  auto r = 0;

  for (;;) {
    auto t = readln.chomp;
    if (t == "END_OF_TEXT") break;
    auto ti = t.split;
    r += ti.count!(a => a == w);
  }

  writeln(r);
}