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

int main()
{
	string s;
	int a[4] = [0,0,0,0];
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(",");
		if(_s[1] == "A") a[0]++;
		if(_s[1] == "B") a[1]++;
		if(_s[1] == "AB") a[2]++;
		if(_s[1] == "O") a[3]++;
	}

	foreach(i;0..4) a[i].writeln;
	return 0;
}