#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;

int main(){
  string W, T;
  int cnt = 0;
  cin>>W;
  while(true){
    cin>>T;
    if(T == "END_OF_TEXT") break;
    for(int i=0;i<T.size();i++){
      if('A' <= T[i] && T[i] <= 'Z'){
	T[i] += 32;
      }
    }
    if(W == T) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

