#!/usr/bin/perl -w

# Exercicio 2 da Aula 26 de MAC211
# M.S.Reis, 15.6.2010

use strict;

my %frequencia;

while(<STDIN>){

    chomp $_;
    my @linha = split " ", $_;

    foreach (@linha){

	my $palavra = uc $_;
        
        if($palavra =~ /^(MAC\d\d\d\d?)$/){

            if( defined $frequencia{$1} ){
	        $frequencia{$1}++; 
	    }
            else{
                $frequencia{$1} = 1;
            }
	}
    }

} # fim do 'while'

foreach my $chave (sort keys %frequencia){
    print $chave . " " . $frequencia{$chave} . "\n";
}

