#include <cstdio>
#include <map>
#include <iostream>
#include <string>

using namespace std;

int main()
{
  map<string, int> blood;
  string str;
  int i;

  blood["A"] = 0;
  blood["B"] = 0;
  blood["O"] = 0;
  blood["AB"] = 0;

  while (cin >> i >> str){
    blood[str]++;
  }
  printf("%d\n", blood[",A"]);
  printf("%d\n", blood[",B"]);
  printf("%d\n", blood[",O"]);
  printf("%d\n", blood[",AB"]);

  return (0);
}