#include <iostream>
#include <string>
using namespace std;
 
int main(void){
   string s,a;
   cin >> s;
   int sum = 0;
   while(cin >> a){
       for (int i=0; i<a.size(); i++){
            if (a[i]<97){
                a[i]=a[i]+32;
            }
        }
        if (a == s){
            sum++;
       }
   }
   cout << sum << endl;
}
