d={t:0for t in'MARCH'};a=0

for t in open(0).read().split():

 if t[0]in d:d[t[0]]+=1

for i in range(32):

 c=t=1

 for j,l in enumerate(d.values()):

  if i>>j&1:t*=l;c+=1

 a+=t*(c==4)

print(a)
from itertools import*;o=ord;d=[0]*128

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

print((sum(d[o(p)]*d[o(q)]*d[o(r)]for p,q,r in combinations('MARCH',3))))
d = {t: 0 for t in "MARCH"}
a = 0
for t in open(0).read().split():
    if t[0] in d:
        d[t[0]] += 1
for i in range(32):
    c = t = 1
    for j, l in enumerate(d.values()):
        if i >> j & 1:
            t *= l
            c += 1
    a += t * (c == 4)
print(a)

from itertools import *

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

-d = {t: 0 for t in "MARCH"} -a = 0 +from itertools import * + +o = ord +d = [0] * 128 -    if t[0] in d: -        d[t[0]] += 1 -for i in range(32): -    c = t = 1 -    for j, l in enumerate(d.values()): -        if i >> j & 1: -            t *= l -            c += 1 -    a += t * (c == 4) -print(a) +    d[o(t[0])] += 1 +print((sum(d[o(p)] * d[o(q)] * d[o(r)] for p, q, r in combinations("MARCH", 3))))