use strict;
use warnings;

my $s;
my @case = (0, 0, 0, 0);
while($s = <>) {
	chomp $s;
	my @arr = split /\,/, $s;
	if($arr[1] eq "A") {
		$case[0]++;
	} elsif($arr[1] eq "B") {
		$case[1]++;
	} elsif($arr[1] eq "AB") {
		$case[2]++;
	} elsif($arr[1] eq "O") {
		$case[3]++;
	}
}

foreach my $i (@case) {
	print "$i\n";
}

exit;