#include <cstdio>

using namespace std;

int main()
{
  int a;
  char b[2];
  int A,B,O,AB;
  A = B = AB = O = 0;

  while(scanf("%d,%s", &a, b)){
    if(b[0] == 'A' && b[1] != 'B'){
      A++;
    }
    if(b[0] == 'B'){
      B++;
    }
    if(b[0] == 'A' && b[1] == 'B'){
      AB++;
    }
    if(b[0] == 'O'){
      O++;
    }
  }

  printf("%d\n%d\n%d\n%d\n", A, B, AB, O);

  return 0;
}