var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.trim().split('\n');

var a = lines.filter(function(line){return line.split(',')[1] == 'A';}).length;
var b = lines.filter(function(line){return line.split(',')[1] == 'B';}).length;
var ab = lines.filter(function(line){return line.split(',')[1] == 'AB';}).length;
var o = lines.filter(function(line){return line.split(',')[1] == 'O';}).length;

console.log(a);
console.log(b);
console.log(ab);
console.log(o);