import std.stdio, std.string, std.uni;

void main() {
    string w = readln.chomp;
    int cnt = 0;
    while (true) {
        string t = readln.chomp;
        if (t == "END_OF_TEXT") break;
        string[] s = t.toLower.split;
        foreach (x; s) {
            if (x == w) ++cnt;
        }
    }
    cnt.writeln;
}
