from itertools import*;d={};g=d.get

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

print((sum(g(p,0)*g(q,0)*g(r,0)for p,q,r in combinations('MARCH',3))))
from itertools import*;d=[0]*128

for t in open(0).read().split():d[ord(t[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 = {}
g = d.get
for t in open(0).read().split():
    d[t[0]] = g(t[0], 0) + 1
print((sum(g(p, 0) * g(q, 0) * g(r, 0) for p, q, r in combinations("MARCH", 3))))

from itertools import *

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

-d = {} -g = d.get +d = [0] * 128 -    d[t[0]] = g(t[0], 0) + 1 -print((sum(g(p, 0) * g(q, 0) * g(r, 0) for p, q, r in combinations("MARCH", 3)))) +    d[ord(t[0])] += 1 +print((sum(p * q * r for p, q, r in combinations([d[ord(t)] for t in "MARCH"], 3))))