#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  map<string, int> mp;
  while (cin >> s) {
    mp[s.substr(s.find(',') + 1)]++;
  }
  cout << mp["A"] << endl;
  cout << mp["B"] << endl;
  cout << mp["AB"] << endl;
  cout << mp["O"] << endl;

  return 0;
}
