#include<iostream>
#include<string>

int main(){
	int a;
	char dummy;
	std::string blood;
	int A=0,B=0,O=0,AB=0;
	while(std::cin>>a>>dummy>>blood){
		if(blood=="A")A++;
		if(blood=="B")B++;
		if(blood=="O")O++;
		if(blood=="AB")AB++;
	}
	std::cout<<A<<std::endl;
	std::cout<<B<<std::endl;
	std::cout<<AB<<std::endl;
	std::cout<<O<<std::endl;
	return 0;
}