#include <string>
#include <iostream>
#include <cctype>
using namespace std;
int main(){

  int i,match=0;
  string W,T;

  cin>>W;

  while(1){

    cin>>T;
    if(T=="END_OF_TEXT")break;
  
  for(i=0; i<T.size(); i++)if(isupper(T[i]))T[i]=tolower(T[i]);
  if(W==T)match++;

  }

  cout<<match<<"\n";

}