l=[input()[0] for _ in range(int(eval(input())))]

import itertools as it

print((sum(x*y*z for x,y,z in it.combinations([l.count(c) for c in 'MARCH'],3))))
_,*l=open(0)

import itertools as it

print((sum(x*y*z for x,y,z in it.combinations([sum(s[0]==c for s in l) for c in 'MARCH'],3))))
l = [input()[0] for _ in range(int(eval(input())))]
import itertools as it

print((sum(x * y * z for x, y, z in it.combinations([l.count(c) for c in "MARCH"], 3))))

_, *l = open(0)
import itertools as it

print(
    (
        sum(
            x * y * z
            for x, y, z in it.combinations(
                [sum(s[0] == c for s in l) for c in "MARCH"], 3
            )
        )
    )
)

-l = [input()[0] for _ in range(int(eval(input())))] +_, *l = open(0) -print((sum(x * y * z for x, y, z in it.combinations([l.count(c) for c in "MARCH"], 3)))) +print( +    ( +        sum( +            x * y * z +            for x, y, z in it.combinations( +                [sum(s[0] == c for s in l) for c in "MARCH"], 3 +            ) +        ) +    ) +)