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

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

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

for s in open(0).readlines():d[ord(s[0])]+=1

print((sum(d[p]*d[q]*d[r]for p,q,r in combinations(list(map(ord,'MARCH')),3))))
from itertools import *

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

from itertools import *

d = [0] * 91
for s in open(0).readlines():
    d[ord(s[0])] += 1
print((sum(d[p] * d[q] * d[r] for p, q, r in combinations(list(map(ord, "MARCH")), 3))))

-for _ in [0] * int(eval(input())): -    d[ord(input()[0])] += 1 +for s in open(0).readlines(): +    d[ord(s[0])] += 1