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

int main()
{
  std::string word;
  std::cin >> word;
  uint count = 0;
  while (std::cin.peek() != EOF) {
    std::string s;
    std::cin >> s;
    std::transform(std::begin(s), std::end(s), std::begin(s), tolower);
    if (s == word) count++;
  }
  std::cout << count << std::endl;
}

