#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
  map<string, int> c; c["A"] = c["B"] = c["AB"] = c["O"] =0;
  int i; char k; string s;
  while (cin >> i >> k >> s) c[s]++;
  cout << c["A"] << endl << c["B"] << endl << c["AB"] << endl << c["O"] << endl;
}