#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string str;
  int a = 0, b = 0, ab = 0, o = 0;
  while (getline(cin, str)) {
    string s = str.substr(str.find_first_of(",")+1);
    if (s == "A") {
      a++;
    } else if (s == "B") {
      b++;
    } else if (s == "O") {
      o++;
    } else {
      ab++;
    }
  }
  cout << a << endl << b << endl << ab << endl << o << endl;
  return 0;
};}