import std.stdio,std.string,std.array;
void main(){
	string line,sw;
	size_t total=0;
	sw = readln().chomp();
	while( 1 ){
		line = readln().chomp();
		if( line == "END_OF_TEXT" ){	break;	}
		foreach( w ; line.split() ){
			if( toLower(w) == toLower(sw) )	total++;
		}
	}
	writeln( total );
}