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)));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()))
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)))
print((sum(p * q * r for p, q, r in combinations(list(map(s.count, "MARCH")), 3))))

-s, *_ = list(zip(*open(0).readlines())) +s, *_ = list(zip(*open(0)))