#include <iostream>
#include <algorithm>

int main(){
    std::string w, t;
    std::cin >> w;

    int count = 0;
    while(std::cin >> t){
        std::transform(t.begin(), t.end(), t.begin(), ::tolower);
        if(t == w){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}
