import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range;
void main() {
	int[string] m;
	m["O"] = 0; m["A"] = 0; m["B"] = 0; m["AB"] = 0;
	string s;
	while( (s=readln.strip).length != 0 ){
		auto as = s.split(',');
		m[as[1]] += 1;
	}
	writeln(m["A"]);
	writeln(m["B"]);
	writeln(m["AB"]);
	writeln(m["O"]);
}