#include <iostream>
#include <string>
using namespace std;

int main(){
	int m,n[4]={0,0,0,0};
	char c,b[][3]={"A","B","AB","O"};
	string s;

	while (cin>>m>>c>>s)
		for (int i=0; i<4; i++)
			if (s==b[i]){
				n[i]++;
				break;
			}
	for (int i=0; i<4; i++) cout<<n[i]<<endl;
}