from itertools import*;s,*_=list(zip(*open(0).readlines()));c=s.count;print((sum(c(p)*c(q)*c(r)for p,q,r in combinations('MARCH',3))))
from itertools import*;s,*_=list(zip(*open(0).readlines()));print((sum(p*q*r for p,q,r in combinations(list(map(s.count,'MARCH')),3))))
from itertools import *

s, *_ = list(zip(*open(0).readlines()))
c = s.count
print((sum(c(p) * c(q) * c(r) for p, q, r in combinations("MARCH", 3))))

from itertools import *

s, *_ = list(zip(*open(0).readlines()))
print((sum(p * q * r for p, q, r in combinations(list(map(s.count, "MARCH")), 3))))

-c = s.count -print((sum(c(p) * c(q) * c(r) for p, q, r in combinations("MARCH", 3)))) +print((sum(p * q * r for p, q, r in combinations(list(map(s.count, "MARCH")), 3))))