from itertools import*;d,o=[0]*91,ord

for _ in[0]*int(eval(input())):d[o(input()[0])]+=1

print((sum(d[p]*d[q]*d[r]for p,q,r in combinations(list(map(o,'MARCH')),3))))
from itertools import*

x=sorted(s[0]for s in open(0).readlines()[1:])

#print(list(x))

c=[len(list(v))for k,v in groupby(x)if k in"MARCH"]

#print(c)

y=combinations(c,3)

#print(list(y))

print((sum(p*q*r for p,q,r in list(y))))
from itertools import *

d, o = [0] * 91, ord
for _ in [0] * int(eval(input())):
    d[o(input()[0])] += 1
print((sum(d[p] * d[q] * d[r] for p, q, r in combinations(list(map(o, "MARCH")), 3))))

from itertools import *

x = sorted(s[0] for s in open(0).readlines()[1:])
# print(list(x))
c = [len(list(v)) for k, v in groupby(x) if k in "MARCH"]
# print(c)
y = combinations(c, 3)
# print(list(y))
print((sum(p * q * r for p, q, r in list(y))))

-d, o = [0] * 91, ord -for _ in [0] * int(eval(input())): -    d[o(input()[0])] += 1 -print((sum(d[p] * d[q] * d[r] for p, q, r in combinations(list(map(o, "MARCH")), 3)))) +x = sorted(s[0] for s in open(0).readlines()[1:]) +# print(list(x)) +c = [len(list(v)) for k, v in groupby(x) if k in "MARCH"] +# print(c) +y = combinations(c, 3) +# print(list(y)) +print((sum(p * q * r for p, q, r in list(y))))