#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main() {
	int count=0;
	string t,w;
	cin >> w;
	while(1){
		cin >> t;
		if(t=="END_OF_TEXT")break;
		rep(i,0,t.length()){
			t[i] = tolower(t[i]); 
		}
		if(t==w)count++;
	}
	cout << count << endl;
	return 0;
}
