import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;
import std.range;
import std.algorithm;

void main()
{
    size_t k = 0;
    auto c = readln.strip.toLower;
    while (!stdin.eof)
    {
        auto a = readln.strip.toLower;
        if (a == "END_OF_TEXT")
            break;
        k += a.split(' ').count(c);
    }
    writeln(k);
}

