#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    string W;
    cin >>W;
    transform(W.begin(), W.end(), W.begin(), ::tolower);
    int count=0;

    for(string str; cin>>str ,str != "END_OF_TEXT";){
        transform(str.begin(),str.end(),str.begin(),::tolower);
        if(str == W) count++;
    }
    cout <<count<<endl;
}
