#include <algorithm>
#include <iostream>
#include <string>

int main() {
  std::string q, s;
  std::cin >> q;

  int count = 0;
  while (std::cin >> s) {
    std::transform(s.begin(), s.end(), s.begin(), tolower);
    if (s == "END_OF_TEXT") break;
    if (s == q) count++;
  }
  std::cout << count << std::endl;
}

