N = int(eval(input()))

names = [0] * 5

pattern = []



def make_pattern(arr, cnt):

    if len(arr) == 5:

        if cnt == 3 :

            pattern.append(arr)

        return

    make_pattern(arr + '1', cnt + 1)

    make_pattern(arr + '0', cnt)



for _ in range(N):

    name = eval(input())

    initial = name[0]

    if 'M' == initial:

        names[0] += 1

    elif 'A' == initial:

        names[1] += 1

    elif 'R' == initial:

        names[2] += 1

    elif 'C' == initial:

        names[3] += 1

    elif 'H' == initial:

        names[4] += 1

    else:

        continue



make_pattern('', 0)



ans = 0

for p in pattern:

    ret = 1

    for i in range(5):

        if p[i] == '1':

            ret *= names[i]

    ans += ret

print(ans) 

from collections import defaultdict

n = int(eval(input()))

h = 'MARCH'

d = [0] * 5

for _ in range(n):

    s = eval(input())

    if s[0] in h:

        d[h.find(s[0])] += 1



ans = 0

for i in range(5):

    for j in range(i, 5):

        if i == j:

            continue

        for k in range(j, 5):

            if i == k or j == k:

                continue

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

print(ans)

N = int(eval(input()))
names = [0] * 5
pattern = []


def make_pattern(arr, cnt):
    if len(arr) == 5:
        if cnt == 3:
            pattern.append(arr)
        return
    make_pattern(arr + "1", cnt + 1)
    make_pattern(arr + "0", cnt)


for _ in range(N):
    name = eval(input())
    initial = name[0]
    if "M" == initial:
        names[0] += 1
    elif "A" == initial:
        names[1] += 1
    elif "R" == initial:
        names[2] += 1
    elif "C" == initial:
        names[3] += 1
    elif "H" == initial:
        names[4] += 1
    else:
        continue
make_pattern("", 0)
ans = 0
for p in pattern:
    ret = 1
    for i in range(5):
        if p[i] == "1":
            ret *= names[i]
    ans += ret
print(ans)

from collections import defaultdict

n = int(eval(input()))
h = "MARCH"
d = [0] * 5
for _ in range(n):
    s = eval(input())
    if s[0] in h:
        d[h.find(s[0])] += 1
ans = 0
for i in range(5):
    for j in range(i, 5):
        if i == j:
            continue
        for k in range(j, 5):
            if i == k or j == k:
                continue
            ans += d[i] * d[j] * d[k]
print(ans)

-N = int(eval(input())) -names = [0] * 5 -pattern = [] +from collections import defaultdict - -def make_pattern(arr, cnt): -    if len(arr) == 5: -        if cnt == 3: -            pattern.append(arr) -        return -    make_pattern(arr + "1", cnt + 1) -    make_pattern(arr + "0", cnt) - - -for _ in range(N): -    name = eval(input()) -    initial = name[0] -    if "M" == initial: -        names[0] += 1 -    elif "A" == initial: -        names[1] += 1 -    elif "R" == initial: -        names[2] += 1 -    elif "C" == initial: -        names[3] += 1 -    elif "H" == initial: -        names[4] += 1 -    else: -        continue -make_pattern("", 0) +n = int(eval(input())) +h = "MARCH" +d = [0] * 5 +for _ in range(n): +    s = eval(input()) +    if s[0] in h: +        d[h.find(s[0])] += 1 -for p in pattern: -    ret = 1 -    for i in range(5): -        if p[i] == "1": -            ret *= names[i] -    ans += ret +for i in range(5): +    for j in range(i, 5): +        if i == j: +            continue +        for k in range(j, 5): +            if i == k or j == k: +                continue +            ans += d[i] * d[j] * d[k]