import itertools

import math



N = int(eval(input()))

S_list = []

for i in range(N):

    S_list.append(eval(input()))



count_M = 0

count_A = 0

count_R = 0

count_C = 0

count_H = 0



for l in S_list:

    if l.startswith('M'):

        count_M += 1

    elif l.startswith('A'):

        count_A += 1

    elif l.startswith('R'):

        count_R += 1

    elif l.startswith('C'):

        count_C += 1

    elif l.startswith('H'):

        count_H += 1



count = [count_M,count_A,count_R,count_C,count_H]

c = list(itertools.combinations(count,3))

x = 0

for i in c:

    i_list = list(i)

    x += i_list[0]*i_list[1]*i_list[2]

print(x)

N = int(eval(input()))

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

res = [0] * 5

ini = 'MARCH'

for i in range(N):

    for j in range(5):

        if S[i][0] == ini[j]:

            res[j] += 1



ans = 0

for i in range(5):

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

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

            ans += res[i]*res[j]*res[k]

print(ans)
import itertools
import math

N = int(eval(input()))
S_list = []
for i in range(N):
    S_list.append(eval(input()))
count_M = 0
count_A = 0
count_R = 0
count_C = 0
count_H = 0
for l in S_list:
    if l.startswith("M"):
        count_M += 1
    elif l.startswith("A"):
        count_A += 1
    elif l.startswith("R"):
        count_R += 1
    elif l.startswith("C"):
        count_C += 1
    elif l.startswith("H"):
        count_H += 1
count = [count_M, count_A, count_R, count_C, count_H]
c = list(itertools.combinations(count, 3))
x = 0
for i in c:
    i_list = list(i)
    x += i_list[0] * i_list[1] * i_list[2]
print(x)

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
res = [0] * 5
ini = "MARCH"
for i in range(N):
    for j in range(5):
        if S[i][0] == ini[j]:
            res[j] += 1
ans = 0
for i in range(5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            ans += res[i] * res[j] * res[k]
print(ans)

-import itertools -import math - -S_list = [] +S = [eval(input()) for _ in range(N)] +res = [0] * 5 +ini = "MARCH" -    S_list.append(eval(input())) -count_M = 0 -count_A = 0 -count_R = 0 -count_C = 0 -count_H = 0 -for l in S_list: -    if l.startswith("M"): -        count_M += 1 -    elif l.startswith("A"): -        count_A += 1 -    elif l.startswith("R"): -        count_R += 1 -    elif l.startswith("C"): -        count_C += 1 -    elif l.startswith("H"): -        count_H += 1 -count = [count_M, count_A, count_R, count_C, count_H] -c = list(itertools.combinations(count, 3)) -x = 0 -for i in c: -    i_list = list(i) -    x += i_list[0] * i_list[1] * i_list[2] -print(x) +    for j in range(5): +        if S[i][0] == ini[j]: +            res[j] += 1 +ans = 0 +for i in range(5): +    for j in range(i + 1, 5): +        for k in range(j + 1, 5): +            ans += res[i] * res[j] * res[k] +print(ans)