#include<iostream>
using namespace std;

int main()
{
  string w, t;
  int count = 0;
  
  cin >> w;
  for (;;) {
    cin >> t;
    if (t == "END_OF_TEXT") break;
    for (string::iterator p = t.begin(); p != t.end(); p++) *p = (char)tolower(*p);
    if (w == t) count++;
  }
  cout << count << endl;

  return 0;
}
