#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string w, t;
    int cnt = 0;
    cin >> w;
    cin >> t;
    while(t != "END_OF_TEXT")
    {
        transform(t.begin(), t.end(), t.begin(), ::tolower);
        if (t == w) cnt++;
        cin >> t;
    }
    cout << cnt << endl;
    return 0;
}

