#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
  map<string,int> blooddata;
  blooddata.insert(map<string,int>::value_type("A",0));
  blooddata.insert(map<string,int>::value_type("B",0));
  blooddata.insert(map<string,int>::value_type("AB",0));
  blooddata.insert(map<string,int>::value_type("O",0));

  int ID;
  char c;
  string blood;
  while(cin>>ID>>c>>blood){
    blooddata[blood]++;
  }

  cout<<blooddata["A"]<<endl;
  cout<<blooddata["B"]<<endl;
  cout<<blooddata["AB"]<<endl;
  cout<<blooddata["O"]<<endl;
}