#include<stdio.h>

int main()
{

int K,TB=0,TA=0,Tab=0,TM=0;
char ch;
while(scanf("%c,%d",&ch,&K)!=EOF)
{
if(ch=='A')TA++;
else if(ch=='B')TB++;
else if(ch=='AB')Tab++;
else if(ch=='O')TM++;
}
printf("%d\n%d\n%d\n%d\n",TA,TB,Tab,TM);

return 0;
}