#include<iostream>
#include<string>
using namespace std;

int main(){
	string W;
	cin>>W;
	string T,tmp;
	int ans=0;
	while(cin>>tmp){
		if(tmp=="END_OF_TEXT")break;
		for(int i=0;i<tmp.length();++i){
			if(tmp[i]>='A' && tmp[i]<='Z')tmp[i]+=0x20;
		}
		if(tmp==W)ans++;
	}
	cout<<ans<<endl;
}
