import std.algorithm, std.array, std.container, std.range;
import std.numeric, std.math, std.bigint, std.random;
import std.string, std.uni, std.regex, std.conv;
import std.bitmanip, core.bitop;
import 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 => icmp(a, w) == 0);
  }

  writeln(r);
}