from collections import defaultdict

import itertools

N = int(eval(input()))

name_dict = defaultdict(list)

for _ in range(N):

    name = eval(input())

    f_n = list(name)[0]

    name_dict[f_n].append(name)

count = 0

start_name = ['M', 'A', 'R', 'C', 'H']

del_list = []

comb_name = list(itertools.combinations(start_name, 3))

for k in list(name_dict.keys()):

    if k not in start_name:

        del_list.append(k)

for k in del_list:

    del name_dict[k]

for name in start_name:

    if name not in name_dict:

        name_dict[name] = []

for comb in comb_name:

    a, b, c = comb

    count += len(name_dict[a]) * len(name_dict[b]) * len(name_dict[c])

print(count)
import itertools

N = int(eval(input()))

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

d = {'M':[], 'A':[], 'R':[], 'C':[], 'H':[]}



for s in S:

    for c in ['M', 'A', 'R', 'C', 'H']:

        if s.startswith(c):

            d[c] += [s]



num = {k: len(d[k]) for k in ['M', 'A', 'R', 'C', 'H']}



ans = 0

for v in itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3):

    tmp = 1

    for c in v:

        tmp *= num[c]

    ans += tmp

print(ans)
from collections import defaultdict
import itertools

N = int(eval(input()))
name_dict = defaultdict(list)
for _ in range(N):
    name = eval(input())
    f_n = list(name)[0]
    name_dict[f_n].append(name)
count = 0
start_name = ["M", "A", "R", "C", "H"]
del_list = []
comb_name = list(itertools.combinations(start_name, 3))
for k in list(name_dict.keys()):
    if k not in start_name:
        del_list.append(k)
for k in del_list:
    del name_dict[k]
for name in start_name:
    if name not in name_dict:
        name_dict[name] = []
for comb in comb_name:
    a, b, c = comb
    count += len(name_dict[a]) * len(name_dict[b]) * len(name_dict[c])
print(count)

import itertools

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
d = {"M": [], "A": [], "R": [], "C": [], "H": []}
for s in S:
    for c in ["M", "A", "R", "C", "H"]:
        if s.startswith(c):
            d[c] += [s]
num = {k: len(d[k]) for k in ["M", "A", "R", "C", "H"]}
ans = 0
for v in itertools.combinations(["M", "A", "R", "C", "H"], 3):
    tmp = 1
    for c in v:
        tmp *= num[c]
    ans += tmp
print(ans)

-from collections import defaultdict -name_dict = defaultdict(list) -for _ in range(N): -    name = eval(input()) -    f_n = list(name)[0] -    name_dict[f_n].append(name) -count = 0 -start_name = ["M", "A", "R", "C", "H"] -del_list = [] -comb_name = list(itertools.combinations(start_name, 3)) -for k in list(name_dict.keys()): -    if k not in start_name: -        del_list.append(k) -for k in del_list: -    del name_dict[k] -for name in start_name: -    if name not in name_dict: -        name_dict[name] = [] -for comb in comb_name: -    a, b, c = comb -    count += len(name_dict[a]) * len(name_dict[b]) * len(name_dict[c]) -print(count) +S = [eval(input()) for _ in range(N)] +d = {"M": [], "A": [], "R": [], "C": [], "H": []} +for s in S: +    for c in ["M", "A", "R", "C", "H"]: +        if s.startswith(c): +            d[c] += [s] +num = {k: len(d[k]) for k in ["M", "A", "R", "C", "H"]} +ans = 0 +for v in itertools.combinations(["M", "A", "R", "C", "H"], 3): +    tmp = 1 +    for c in v: +        tmp *= num[c] +    ans += tmp +print(ans)