N = int(eval(input()))

name = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}

march = "MARCH"

for _ in range(N):

  S = eval(input())

  if(S[0] in name):

    name[S[0]] += 1

ans = 0

for i in range(3):

  for j in range(i+1,4):

    for k in range(j+1,5):

      ans += name[march[i]] * name[march[j]] * name[march[k]]

print(ans)
N = int(eval(input()))

S = [eval(input()) for _ in range(N)]



head = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}

march = "MARCH"

for s in S:

  if(s[0] in head):

    head[s[0]] += 1

ans = 0

for i in range(3):

  for j in range(i+1,4):

    for k in range(j+1,5):

      ans += head[march[i]] * head[march[j]] * head[march[k]]

print(ans)
N = int(eval(input()))
name = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
march = "MARCH"
for _ in range(N):
    S = eval(input())
    if S[0] in name:
        name[S[0]] += 1
ans = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += name[march[i]] * name[march[j]] * name[march[k]]
print(ans)

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
head = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
march = "MARCH"
for s in S:
    if s[0] in head:
        head[s[0]] += 1
ans = 0
for i in range(3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += head[march[i]] * head[march[j]] * head[march[k]]
print(ans)

-name = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} +S = [eval(input()) for _ in range(N)] +head = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} -for _ in range(N): -    S = eval(input()) -    if S[0] in name: -        name[S[0]] += 1 +for s in S: +    if s[0] in head: +        head[s[0]] += 1 -            ans += name[march[i]] * name[march[j]] * name[march[k]] +            ans += head[march[i]] * head[march[j]] * head[march[k]]