#include <iostream>
#include <string>
int main(){
	int n[]={0,0,0,0},i;
	std::string s;
	while (std::cin>>i>>s){
		s=s.substr(1);
		n[(s=="A")?3:(s=="B")?2:(s=="O")?0:1]++;
	}
	i=4;
	while (i--) std::cout<<n[i]<<"\n";
}