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

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

    char[][] ss;
    foreach(line; stdin.byLine){
        line = line.chomp;
        if(line == "END_OF_TEXT") break;
        ss ~= line.chomp.toLower.split;
    }

    writeln(ss.count(w));
}