import itertools

from collections import Counter

N = int(eval(input()))

src = [eval(input()) for i in range(N)]

ctr = Counter()

for s in src:

    ctr[s[0]] += 1



ans = 0

for ptn in itertools.combinations('MARCH',3):

    a,b,c = ptn

    ans += ctr[a]*ctr[b]*ctr[c]

print(ans)
N = int(eval(input()))

S = [eval(input()) for i in range(N)]

from collections import Counter

ctr = Counter([s[0] for s in S])



ans = 0

import itertools

for ptn in itertools.combinations('MARCH', 3):

    t = 1

    for c in ptn:

        t *= ctr[c]

    ans += t

print(ans)
import itertools
from collections import Counter

N = int(eval(input()))
src = [eval(input()) for i in range(N)]
ctr = Counter()
for s in src:
    ctr[s[0]] += 1
ans = 0
for ptn in itertools.combinations("MARCH", 3):
    a, b, c = ptn
    ans += ctr[a] * ctr[b] * ctr[c]
print(ans)

N = int(eval(input()))
S = [eval(input()) for i in range(N)]
from collections import Counter

ctr = Counter([s[0] for s in S])
ans = 0
import itertools

for ptn in itertools.combinations("MARCH", 3):
    t = 1
    for c in ptn:
        t *= ctr[c]
    ans += t
print(ans)

-import itertools +N = int(eval(input())) +S = [eval(input()) for i in range(N)] -N = int(eval(input())) -src = [eval(input()) for i in range(N)] -ctr = Counter() -for s in src: -    ctr[s[0]] += 1 +ctr = Counter([s[0] for s in S]) +import itertools + -    a, b, c = ptn -    ans += ctr[a] * ctr[b] * ctr[c] +    t = 1 +    for c in ptn: +        t *= ctr[c] +    ans += t