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

int main()
{
	int num ;
	char Blod[3] ;
	int Btype[4] = { 0,0,0,0 } ;

	while( scanf( "%d,%s", &num,&Blod ) != EOF  )
	{

		if( Blod[0] == 'A' )
		{
			if( Blod[1] == 'B' ) Btype[2] ++ ;
			else Btype[0] ++ ;
		}
		else if( Blod[0] == 'B' ) Btype[1] ++ ;
		else if( Blod[0] == 'O' ) Btype[3] ++ ;
	}

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

	return 0 ;
}