program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,i,j,k,cnt(5),ans
    character(10),allocatable:: s(:)
    character(5),parameter:: march = 'MARCH'
    character(1):: initial
    logical:: change

    read*, n
    allocate(s(n))
    cnt(:) = 0
    do i=1,n
        read*, s(i)
        initial = s(i)(1:1)
        do j=1,5
            if (initial == march(j:j)) then
                cnt(j)=cnt(j)+1
                exit
            end if
        end do
    end do
    change=.true.
    do while(change)
        change=.false.
        do i=1,4
            if (cnt(i) < cnt(i+1)) then
                change=.true.
                call swap(cnt(i),cnt(i+1))
            end if
        end do
    end do

    ans=0
    do i=1,3
        do j=i+1,4
            do k=j+1,5
                ans=ans+cnt(i)*cnt(j)*cnt(k)
            end do
        end do
    end do
    print'(i0)', ans
contains
subroutine swap(x,y)
    integer(int64):: x,y,t
    t=x;x=y;y=t
end subroutine
end program name