import std.stdio,
       std.string,
       std.conv;

void main(){
	string s, w = readln.chomp;
	while(true){
		string tmp = readln.chomp;
		if (tmp == "END_OF_TEXT") break;
		s ~= tmp.toLower ~ " ";
	}
	int c = 0;
	foreach(x; s.split){
		if (x == w) c++;
	}

	writeln(c);
}