from itertools import*;d=[0]*91

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

print((sum(p*q*r for p,q,r in combinations([d[ord(t)]for t in'MARCH'],3))))
from itertools import*;d={}

for t in open(0).read().split():d[t[0]]=d.get(t[0],0)+1

print((sum(p*q*r for p,q,r in combinations([d.get(t,0)for t in'MARCH'],3))))
from itertools import *

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

from itertools import *

d = {}
for t in open(0).read().split():
    d[t[0]] = d.get(t[0], 0) + 1
print((sum(p * q * r for p, q, r in combinations([d.get(t, 0) for t in "MARCH"], 3))))

-d = [0] * 91 -for _ in [0] * int(eval(input())): -    d[ord(input()[0])] += 1 -print((sum(p * q * r for p, q, r in combinations([d[ord(t)] for t in "MARCH"], 3)))) +d = {} +for t in open(0).read().split(): +    d[t[0]] = d.get(t[0], 0) + 1 +print((sum(p * q * r for p, q, r in combinations([d.get(t, 0) for t in "MARCH"], 3))))