N=int(input())

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

for n in range(N):

    S=list(input())

    if S[0] in name_dict:

        name_dict[S[0]]+=1



ans=name_dict['M']*name_dict['A']*name_dict['R']\

    +name_dict['M']*name_dict['A']*name_dict['C']\

    +name_dict['M']*name_dict['A']*name_dict['H']\

    +name_dict['M']*name_dict['R']*name_dict['C']\

    +name_dict['M']*name_dict['R']*name_dict['H']\

    +name_dict['M']*name_dict['C']*name_dict['H']\

    +name_dict['A']*name_dict['R']*name_dict['C']\

    +name_dict['A']*name_dict['R']*name_dict['H']\

    +name_dict['A']*name_dict['C']*name_dict['H']\

    +name_dict['R']*name_dict['C']*name_dict['H']

print(ans)

n = int(eval(input()))

c = [0 for i in range(5)]

for i in range(n):

    s = eval(input())

    if s[0] == 'M':

        c[0] += 1

    elif s[0] == 'A':

        c[1] += 1

    elif s[0] == 'R':

        c[2] += 1

    elif s[0] == 'C':

        c[3] += 1

    elif s[0] == 'H':

        c[4] += 1

from itertools import combinations

ans = 0

for v in combinations([0,1,2,3,4], 3):

    ans += c[v[0]]*c[v[1]]*c[v[2]]

print(ans)
N = int(input())
name_dict = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for n in range(N):
    S = list(input())
    if S[0] in name_dict:
        name_dict[S[0]] += 1
ans = (
    name_dict["M"] * name_dict["A"] * name_dict["R"]
    + name_dict["M"] * name_dict["A"] * name_dict["C"]
    + name_dict["M"] * name_dict["A"] * name_dict["H"]
    + name_dict["M"] * name_dict["R"] * name_dict["C"]
    + name_dict["M"] * name_dict["R"] * name_dict["H"]
    + name_dict["M"] * name_dict["C"] * name_dict["H"]
    + name_dict["A"] * name_dict["R"] * name_dict["C"]
    + name_dict["A"] * name_dict["R"] * name_dict["H"]
    + name_dict["A"] * name_dict["C"] * name_dict["H"]
    + name_dict["R"] * name_dict["C"] * name_dict["H"]
)
print(ans)

n = int(eval(input()))
c = [0 for i in range(5)]
for i in range(n):
    s = eval(input())
    if s[0] == "M":
        c[0] += 1
    elif s[0] == "A":
        c[1] += 1
    elif s[0] == "R":
        c[2] += 1
    elif s[0] == "C":
        c[3] += 1
    elif s[0] == "H":
        c[4] += 1
from itertools import combinations

ans = 0
for v in combinations([0, 1, 2, 3, 4], 3):
    ans += c[v[0]] * c[v[1]] * c[v[2]]
print(ans)

-N = int(input()) -name_dict = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} -for n in range(N): -    S = list(input()) -    if S[0] in name_dict: -        name_dict[S[0]] += 1 -ans = ( -    name_dict["M"] * name_dict["A"] * name_dict["R"] -    + name_dict["M"] * name_dict["A"] * name_dict["C"] -    + name_dict["M"] * name_dict["A"] * name_dict["H"] -    + name_dict["M"] * name_dict["R"] * name_dict["C"] -    + name_dict["M"] * name_dict["R"] * name_dict["H"] -    + name_dict["M"] * name_dict["C"] * name_dict["H"] -    + name_dict["A"] * name_dict["R"] * name_dict["C"] -    + name_dict["A"] * name_dict["R"] * name_dict["H"] -    + name_dict["A"] * name_dict["C"] * name_dict["H"] -    + name_dict["R"] * name_dict["C"] * name_dict["H"] -) +n = int(eval(input())) +c = [0 for i in range(5)] +for i in range(n): +    s = eval(input()) +    if s[0] == "M": +        c[0] += 1 +    elif s[0] == "A": +        c[1] += 1 +    elif s[0] == "R": +        c[2] += 1 +    elif s[0] == "C": +        c[3] += 1 +    elif s[0] == "H": +        c[4] += 1 +from itertools import combinations + +ans = 0 +for v in combinations([0, 1, 2, 3, 4], 3): +    ans += c[v[0]] * c[v[1]] * c[v[2]]