#include <cstdio>
#include<iostream>
#include<string>

using namespace std;
 
int main(void){

	int g;
	char g2;
	string blood;
	string numbl[4]={"A","B","AB","O"};
	int nubl[4]={0};

	while(cin>>g>>g2>>blood){
		for(int i=0;i<4;i++){
			if(blood==numbl[i]) nubl[i]++;
		}
	}

	for(int i=0;i<4;i++){
		cout<<nubl[i]<<endl;
	}

    return 0;
}