#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main(){
  int num;int a=0,b=0,ab=0,o=0;
  string blood;
  while(scanf("%d,%s",&num,&blood)!=EOF){
    if(blood=="A")a++;
    else if(blood=="B")b++;
    else if(blood=="AB")ab++;
    else if(blood=="O")o++;
    else cout<<"?????????????¶??????????????????´????????????"<<endl;
    }
  cout<<a<<endl<<b<<endl<<ab<<endl<<o<<endl;
}