There are N people. The name of the i-th person is S_i.
We would like to choose three people so that the following conditions are met:
 - The name of every chosen person begins with M, A, R, C or H.
 - There are no multiple people whose names begin with the same letter.
How many such ways are there to choose three people, disregarding order?
Note that the answer may not fit into a 32-bit integer type.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - S_i consists of uppercase English letters.
 - 1 \leq |S_i| \leq 10
 - S_i \neq S_j (i \neq j)

-----Input-----
Input is given from Standard Input in the following format:
N
S_1
:
S_N

-----Output-----
If there are x ways to choose three people so that the given conditions are met, print x.

-----Sample Input-----
5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI

-----Sample Output-----
2

We can choose three people with the following names:
 - MASHIKE, RUMOI, HABORO
 - MASHIKE, RUMOI, HOROKANAI
Thus, we have two ways.

Difficulty: EASY

Solutions:
from itertools import combinations as cmbs
import sys
c = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(int(input())):
	si = sys.stdin.readline()[0]
	if si in c:
		c[si] += 1
ans = sum((i * j * k for (i, j, k) in cmbs(c.values(), r=3)))
print(ans)


import itertools
N = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
	S = input()
	if S[0] in d:
		d[S[0]] += 1
ans = 0
for (i, j, k) in itertools.combinations(d.keys(), 3):
	ans += d[i] * d[j] * d[k]
print(ans)


from collections import Counter
N = int(input())
S = [input()[:1] for _ in range(N)]
c = Counter(S)
first_name = 'MARCH'
c = [c[i] for i in first_name if c[i]]
ans = 0
if len(c) > 2:
	ans += c[0] * c[1] * c[2]
if len(c) > 3:
	for i in c[3:]:
		for j in range(3):
			tmp = c[:3]
			tmp[j] = i
			ans += tmp[0] * tmp[1] * tmp[2]
if len(c) > 4:
	tmp = c[3:]
	for j in range(3):
		ans += tmp[0] * tmp[1] * c[j]
print(ans)


from itertools import combinations
(n, *S) = open(0).read().split()
cap = [s[0] for s in S]
cnt = [cap.count(i) for i in 'MARCH']
ans = sum((x * y * z for (x, y, z) in combinations(cnt, 3)))
print(ans)


N = int(input())
M = []
A = []
R = []
C = []
H = []
for _ in range(N):
	s = input()
	if s.startswith('M'):
		M.append(s)
	if s.startswith('A'):
		A.append(s)
	if s.startswith('R'):
		R.append(s)
	if s.startswith('C'):
		C.append(s)
	if s.startswith('H'):
		H.append(s)
m = len(M)
a = len(A)
r = len(R)
c = len(C)
h = len(H)
ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h
print(ans)


import itertools
n = int(input())
d = {'M': 0, 'A': 1, 'R': 2, 'C': 3, 'H': 4}
h = [0, 0, 0, 0, 0]
for _ in range(n):
	name = input()
	if name[0] in d.keys():
		h[d[name[0]]] += 1
ans = 0
for (i, j, k) in itertools.combinations([0, 1, 2, 3, 4], 3):
	ans += h[i] * h[j] * h[k]
print(ans)


from itertools import combinations
N = int(input())
nums = {}
for i in 'MARCH':
	nums[i] = 0
for i in range(N):
	s = input().strip()
	if s[0] in 'MARCH':
		nums[s[0]] += 1
ct = 0
for (a, b, c) in combinations('MARCH', 3):
	ct += nums[a] * nums[b] * nums[c]
print(ct)


import itertools
n = int(input())
a = ['M', 'A', 'R', 'C', 'H']
b = [0] * 5
for i in range(n):
	s = input()
	for j in range(5):
		if a[j] == s[0]:
			b[j] += 1
ans = 0
for k in itertools.combinations(b, 3):
	ans += k[0] * k[1] * k[2]
print(ans)


from collections import Counter
from itertools import combinations
N = int(input())
S = [input() for i in range(N)]
xs = Counter((s[0] for s in S))
print(sum((xs[a] * xs[b] * xs[c] for (a, b, c) in combinations('MARCH', 3))))


import itertools
from collections import Counter
N = int(input())
src = [input() for i in range(N)]
ctr = Counter()
for s in src:
	ctr[s[0]] += 1
ans = 0
for ptn in itertools.combinations('MARCH', 3):
	(a, b, c) = ptn
	ans += ctr[a] * ctr[b] * ctr[c]
print(ans)


from itertools import combinations as C
d = {}
for _ in range(int(input())):
	s = input()[0]
	if s in 'MARCH':
		d[s] = d.get(s, 0) + 1
else:
	print(sum([p * q * r for (p, q, r) in C(d.values(), 3)]))


from itertools import combinations
N = int(input())
march = [0] * 5
for _ in range(N):
	S = input()
	S = S[0]
	if S == 'M':
		march[0] += 1
	elif S == 'A':
		march[1] += 1
	elif S == 'R':
		march[2] += 1
	elif S == 'C':
		march[3] += 1
	elif S == 'H':
		march[4] += 1
ls = list(combinations(range(5), 3))
ans = 0
for (i, j, k) in ls:
	ans += march[i] * march[j] * march[k]
print(ans)


from collections import defaultdict
import itertools
N = int(input())
d = defaultdict(int)
for i in range(N):
	d[input()[0]] += 1
ans = 0
for (A, B, C) in itertools.combinations('MARCH', 3):
	ans += d[A] * d[B] * d[C]
print(ans)


import itertools
n = int(input())
data = [[] for i in range(5)]
for i in range(n):
	tmp = str(input())
	if tmp[0] == 'M':
		data[0].append(tmp)
	elif tmp[0] == 'A':
		data[1].append(tmp)
	elif tmp[0] == 'R':
		data[2].append(tmp)
	elif tmp[0] == 'C':
		data[3].append(tmp)
	elif tmp[0] == 'H':
		data[4].append(tmp)
ans = 0
for (i, j, k) in itertools.combinations([0, 1, 2, 3, 4], 3):
	ans += len(data[i]) * len(data[j]) * len(data[k])
print(ans)


n = int(input())
dic = {}
cnt = 0
for i in range(n):
	s = input()
	if s[0] == 'M' or s[0] == 'A' or s[0] == 'R' or (s[0] == 'C') or (s[0] == 'H'):
		if s[0] in dic:
			dic[s[0]] += 1
		else:
			dic[s[0]] = 1
lis = [x for x in dic.values()]
for j in range(len(lis) - 2):
	for k in range(j + 1, len(lis) - 1):
		for l in range(k + 1, len(lis)):
			cnt += lis[j] * lis[k] * lis[l]
print(cnt)


N = int(input())
KEY = 'MARCH'
d = {}
for i in KEY:
	d[i] = 0
for i in range(N):
	t = input()[0]
	if t in KEY:
		d[t] += 1
ans = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += d[KEY[i]] * d[KEY[j]] * d[KEY[k]]
print(ans)


from itertools import combinations as C
d = {}
for _ in range(int(input())):
	s = input()[0]
	d[s] = d.get(s, 0) + 1
dk = set(d.keys()) & set('MARCH')
ans = 0
for (p, q, r) in C(dk, 3):
	ans += d[p] * d[q] * d[r]
else:
	print(ans)


from itertools import combinations
N = int(input())
d = [0] * 128
for _ in range(N):
	d[ord(input()[0])] += 1
print(sum([d[ord(p0)] * d[ord(p1)] * d[ord(p2)] for (p0, p1, p2) in combinations('MARCH', 3)]))


n = int(input())
p = []
for i in range(n):
	s = input()
	p.append(s[0])
m = p.count('M')
a = p.count('A')
r = p.count('R')
c = p.count('C')
h = p.count('H')
print(m * a * r + m * a * h + m * a * c + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h)


import itertools
n = int(input())
m = list('MARCH')
d = [0] * 5
for i in range(n):
	s = input()
	for j in range(len(m)):
		if s[0] == m[j]:
			d[j] += 1
ans = 0
for i in list(itertools.combinations(list(range(5)), 3)):
	k = list(i)
	ans += d[k[0]] * d[k[1]] * d[k[2]]
print(ans)


from itertools import combinations
n = int(input())
s = [input()[0] for _ in range(n)]
c = [s.count(i) for i in 'MARCH']
print(sum((c[i] * c[j] * c[k] for (i, j, k) in combinations(range(5), 3))))


from collections import defaultdict
from itertools import combinations
N = int(input())
D = defaultdict(int)
for _ in range(N):
	S = input()
	if S[0] in 'MARCH':
		D[S[0]] += 1
ans = 0
for C in combinations(('M', 'A', 'R', 'C', 'H'), 3):
	temp = 1
	for c in C:
		temp *= D[c]
	ans += temp
print(ans)


n = int(input())
march = [0] * 5
march_dic = {'M': 0, 'A': 1, 'R': 2, 'C': 3, 'H': 4}
for i in range(n):
	name = input()
	if name[0] in 'MARCH':
		march[march_dic[name[0]]] += 1

def count_type(march):
	ans = []
	for i in march:
		if i != 0:
			ans.append(i)
	ans.sort()
	return (len(ans), ans)
(type_num, each_num) = count_type(march)
if type_num < 3:
	print(0)
else:
	ans = 0
	for i in range(type_num - 2):
		for j in range(i + 1, type_num - 1):
			for k in range(j + 1, type_num):
				ans += each_num[i] * each_num[j] * each_num[k]
	print(ans)


N = int(input())
name = [input()[0] for _ in range(N)]
m = name.count('M')
a = name.count('A')
r = name.count('R')
c = name.count('C')
h = name.count('H')
print(m * a * (r + c + h) + m * r * (c + h) + m * c * h + a * r * (c + h) + a * c * h + r * c * h)


N = int(input())
count = [0] * 5
for i in range(N):
	tmp = input()
	if tmp[0] == 'M':
		count[0] += 1
	if tmp[0] == 'A':
		count[1] += 1
	if tmp[0] == 'R':
		count[2] += 1
	if tmp[0] == 'C':
		count[3] += 1
	if tmp[0] == 'H':
		count[4] += 1
ans = 0
for i in range(0, 3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += count[i] * count[j] * count[k]
print(ans)


N = int(input())
MARCH = [0, 0, 0, 0, 0]
for i in range(0, N):
	S = str(input())
	if S[0] == 'M':
		MARCH[0] += 1
	if S[0] == 'A':
		MARCH[1] += 1
	if S[0] == 'R':
		MARCH[2] += 1
	if S[0] == 'C':
		MARCH[3] += 1
	if S[0] == 'H':
		MARCH[4] += 1
import itertools as it
mokou = list(it.product([0, 1], repeat=5))
count = 0
for i in range(0, len(mokou)):
	if sum(mokou[i]) == 3:
		zen = 1
		for j in range(0, 5):
			if mokou[i][j] == 1:
				zen = zen * MARCH[j]
		count += zen
print(count)


n = int(input())
s = [input()[0] for _ in [0] * n]
l = ['M', 'A', 'R', 'C', 'H']
L = [s.count(x) for x in l]
a = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			a += L[i] * L[j] * L[k]
print(a)


n = int(input())
dict = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(n):
	s = input()
	if s[0] in dict:
		dict[s[0]] += 1
data = ['M', 'A', 'R', 'C', 'H']
ans = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += dict[data[i]] * dict[data[j]] * dict[data[k]]
print(ans)


import itertools
n = int(input())
s = [input()[0] for _ in range(n)]
c = list(itertools.combinations(set(filter(lambda x: x in 'MARCH', s)), 3))
ans = 0
for _c in c:
	ans += s.count(_c[0]) * s.count(_c[1]) * s.count(_c[2])
print(ans)


from itertools import *
N = int(input())
S = [input() for n in range(N)]
D = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for s in S:
	if s[0] in 'MARCH':
		D[s[0]] += 1
print(sum((a * b * c for (a, b, c) in combinations(D.values(), 3))))


from itertools import combinations
import collections
N = int(input())
A = []
for i in range(N):
	A.append(input()[0])
C = collections.Counter(A)
print(sum((C[a] * C[b] * C[c] for (a, b, c) in combinations('MARCH', 3))))


from itertools import *
x = [s[0] for s in open(0).readlines()]
print(sum((p * q * r for (p, q, r) in combinations([x.count(s) for s in 'MARCH'], 3))))


import itertools
(n, *s) = open(0).read().split()
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in s:
	k = i[0]
	if k in d:
		d[k] += 1
p = 0
for (i, j, k) in itertools.combinations(d.values(), 3):
	p += i * j * k
print(p)


N = int(input())
S = [input()[0] for i in range(N)]
M = S.count('M')
A = S.count('A')
R = S.count('R')
C = S.count('C')
H = S.count('H')
print(M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H)


from collections import Counter
from itertools import combinations
N = int(input())
S = Counter((input()[0] for _ in range(N)))
ans = 0
for (i, j, k) in combinations('MARCH', 3):
	ans += S[i] * S[j] * S[k]
print(ans)


from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = 0
c = Counter((x[0] for x in s))
for x in s:
	if x[0] in 'MARCH':
		cnt += 1
ans = cnt * (cnt - 1) * (cnt - 2) // 6
for (k, v) in list(c.items()):
	if k not in 'MARCH':
		continue
	if v >= 2:
		ans -= v * (v - 1) // 2 * (cnt - v)
	if v >= 3:
		ans -= v * (v - 1) * (v - 2) // 6
print(ans)


n = int(input())
s = []
cnt = [0] * 5
l = ['M', 'A', 'R', 'C', 'H']
ans = 0
for i in range(n):
	s.append(input())
for i in s:
	if i[0] in l:
		cnt[l.index(i[0])] += 1
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += cnt[i] * cnt[j] * cnt[k]
print(ans)


N = int(input())
S = [input()[0] for _ in range(N)]
from collections import Counter
S = Counter(S)
M = S['M']
A = S['A']
R = S['R']
C = S['C']
H = S['H']
print(M * A * (R + C + H) + (M + A) * R * (C + H) + (M + A + R) * C * H)


N = int(input())
S = [input()[0] for i in range(N)]
m = S.count('M')
a = S.count('A')
r = S.count('R')
c = S.count('C')
h = S.count('H')
print(m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h)


from collections import defaultdict
N = int(input())
defdict = defaultdict(int)
for _ in range(N):
	st = input()
	fst = st[0]
	if fst in 'MARCH':
		defdict[fst] += 1
V = list(defdict.values())
NV = len(V)
ans = 0
for i in range(NV):
	for j in range(i + 1, NV):
		for k in range(j + 1, NV):
			ans += V[i] * V[j] * V[k]
print(ans)


import itertools as i, collections as c
(n, *a) = open(0).read().split()
print(sum((p * q * r for (p, q, r) in i.combinations(c.Counter((s[0] for s in a if s[0] in 'MARCH')).values(), 3))))


import itertools
n = int(input())
ls = [input()[:1] for _ in range(n)]
ans = 0
cmb = list(itertools.combinations(list('MARCH'), 3))
for c in cmb:
	ans += ls.count(c[0]) * ls.count(c[1]) * ls.count(c[2])
print(ans)


from collections import Counter
from itertools import combinations
n = int(input())
l = Counter((input()[0] for _ in range(n)))
con = [l[c] for c in 'MARCH' if c in l]
print(sum((a * b * c for (a, b, c) in combinations(con, 3))))


from collections import Counter
from itertools import combinations
n = int(input())
s = [input()[0] for _ in range(n)]
C = Counter(s)
ans = 0
for (x, y, z) in combinations('MARCH', 3):
	ans += C[x] * C[y] * C[z]
print(ans)


from itertools import combinations
N = int(input())
s = [input() for _ in range(N)]
cnt = [sum((v[0] == c for v in s)) for c in 'MARCH']
ans = sum((cnt[i] * cnt[j] * cnt[k] for (i, j, k) in combinations(range(5), 3)))
print(ans)


n = int(input())
Mnum = 0
Anum = 0
Rnum = 0
Cnum = 0
Hnum = 0
for i in range(n):
	a = input()
	if a[0] == 'M':
		Mnum += 1
	elif a[0] == 'A':
		Anum += 1
	elif a[0] == 'R':
		Rnum += 1
	elif a[0] == 'C':
		Cnum += 1
	elif a[0] == 'H':
		Hnum += 1
alist = []
alist.append(Mnum)
alist.append(Anum)
alist.append(Rnum)
alist.append(Cnum)
alist.append(Hnum)
from itertools import combinations
print(sum([a * b * c for (a, b, c) in combinations(alist, 3)]))


from collections import defaultdict
from itertools import combinations

def inpl():
	return list(map(int, input().split()))
C = defaultdict(int)
N = int(input())
for _ in range(N):
	C[input()[0]] += 1
res = 0
for H in combinations('MARCH', r=3):
	res += C[H[0]] * C[H[1]] * C[H[2]]
print(res)


N = int(input())
head = 'MARCH'
count = [0] * 5
answer = 0
for i in range(N):
	S = input()
	for j in range(5):
		if S[0] == head[j]:
			count[j] += 1
for i in range(5):
	for j in range(i):
		for k in range(j):
			answer += count[i] * count[j] * count[k]
print(answer)


import io
import sys
from itertools import combinations as comb
(n, *S) = open(0).read().split()
s = [i[0] for i in S]
array = [s.count(i) for i in 'MARCH']
ret = sum((x * y * z for (x, y, z) in comb(array, 3)))
print(ret)


N = int(input())
text = 'MARCH'
d = {a: 0 for a in text}
for _ in range(N):
	s = input()[0]
	if s in text:
		d[s] += 1
tot = 0
L = [v for (k, v) in list(d.items())]
for i in range(0, 5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			tot += L[i] * L[k] * L[j]
print(tot)


import sys
from collections import Counter
from itertools import combinations
inint = lambda : int(sys.stdin.readline())
inintm = lambda : map(int, sys.stdin.readline().split())
inintl = lambda : list(inintm())
instrm = lambda : map(str, sys.stdin.readline().split())
instrl = lambda : list(instrm())
n = inint()
S = []
ans = 0
for i in range(n):
	s = input()[0]
	if s in ['M', 'A', 'R', 'C', 'H']:
		S.append(s)
C = Counter(S)
for w in combinations(['M', 'A', 'R', 'C', 'H'], 3):
	ans += C[w[0]] * C[w[1]] * C[w[2]]
print(ans)


from itertools import *
d = [0] * 128
for t in open(0).read().split():
	d[ord(t[0])] += 1
print(sum((p * q * r for (p, q, r) in combinations([d[ord(t)] for t in 'MARCH'], 3))))


n = int(input())
k = [0] * 5
for _ in range(n):
	s = input()[0]
	if s == 'M':
		k[0] += 1
	elif s == 'A':
		k[1] += 1
	elif s == 'R':
		k[2] += 1
	elif s == 'C':
		k[3] += 1
	elif s == 'H':
		k[4] += 1
ans = 0
for i in range(32):
	bit = bin(i)[2:].zfill(5)
	if bit.count('1') != 3:
		continue
	count = 1
	for j in range(5):
		if bit[j] == '1':
			count *= k[j]
	ans += count
print(ans)


from itertools import combinations
(n, *s) = map(str, open(0).read().split())
a = [0] * 5
for i in s:
	if i[0] in 'MARCH':
		a['MARCH'.index(i[0])] += 1
print(sum([a[x] * a[y] * a[z] for (x, y, z) in combinations(range(5), 3)]))


n = int(input())
U = list()
for i in range(n):
	i = input()
	U.append(i)
m = a = r = c = h = 0
for x in U:
	if x[0] == 'M':
		m += 1
	if x[0] == 'A':
		a += 1
	if x[0] == 'R':
		r += 1
	if x[0] == 'C':
		c += 1
	if x[0] == 'H':
		h += 1
sig = (m + a + r) * c * h + m * a * (r + c + h) + (m + a) * r * (c + h)
print(sig)


from itertools import combinations

def main():
	s = [i[0] for i in open(0).read().split()[1:]]
	c = (s.count('M'), s.count('A'), s.count('R'), s.count('C'), s.count('H'))
	a = sum((x * y * z for (x, y, z) in combinations(c, 3)))
	print(a)
main()


n = int(input())
A = ''
for i in range(n):
	a = input()
	A += a[0]
m = A.count('M')
a = A.count('A')
r = A.count('R')
c = A.count('C')
h = A.count('H')
ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h
print(ans)


import itertools
n = int(input())
s = []
for _ in range(n):
	s.append(input())
m = [0] * 5
p = ['M', 'A', 'R', 'C', 'H']
for x in s:
	for i in range(5):
		if x[0] == p[i]:
			m[i] += 1
ans = 0
for v in itertools.combinations(m, 3):
	ans += v[0] * v[1] * v[2]
print(ans)


from collections import Counter
from itertools import combinations
n = int(input())
S = [input()[0] for _ in range(n)]
C = Counter(S)
ans = 0
for (i, j, k) in combinations(['M', 'A', 'R', 'C', 'H'], 3):
	ans += C[i] * C[j] * C[k]
print(ans)


import sys

def solve():
	input = sys.stdin.readline
	N = int(input())
	D = dict()
	W = ['M', 'A', 'R', 'C', 'H']
	for w in W:
		D[w] = 0
	for _ in range(N):
		S = input().strip('\n')
		if S[0] in W:
			D[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 += D[W[i]] * D[W[j]] * D[W[k]]
	print(ans)
	return 0

def __starting_point():
	solve()
__starting_point()


from itertools import combinations
N = int(input())
name_count = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
	name = input()
	if name[0] in name_count:
		name_count[name[0]] += 1

def comb(n, r):
	up = 1
	down = 1
	for i in range(r):
		up *= n - i
		down *= i + 1
	return up // down
all_sum = sum(name_count.values())
total = comb(all_sum, 3)
for i in list(name_count.values()):
	if i >= 2:
		total -= comb(i, 2) * (all_sum - i)
	if i >= 3:
		total -= comb(i, 3)
print(total)


import itertools
n = int(input())
li = []
for i in range(n):
	li.append(input()[0])
tm = list(itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3))
ans = 0
for (j1, j2, j3) in tm:
	ans += li.count(j1) * li.count(j2) * li.count(j3)
print(ans)


n = int(input())
name_list = [0, 0, 0, 0, 0]
alp = ['M', 'A', 'R', 'C', 'H']
for i in range(n):
	s = input()
	if s[0] in alp:
		name_list[alp.index(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_list[i] * name_list[j] * name_list[k]
print(ans)


import collections
import itertools
N = int(input())
S = [input()[0] for _ in range(N)]
A = []
ans = 0
for i in S:
	if i == 'M' or i == 'A' or i == 'R' or (i == 'C') or (i == 'H'):
		A.append(i)
if len(A) != 0:
	C = collections.Counter(A).most_common()
	(v, c) = list(zip(*C))
	for (a, b, c) in itertools.combinations(c, 3):
		ans += a * b * c
print(ans)


from collections import Counter
import itertools
N = int(input())
S = [input()[0] for _ in range(N)]
counter = Counter(S)
ans = 0
for (x, y, z) in itertools.combinations('MARCH', 3):
	ans += counter[x] * counter[y] * counter[z]
print(ans)


l = [input()[0] for _ in range(int(input()))]
import itertools as it
print(sum((x * y * z for (x, y, z) in it.combinations([l.count(c) for c in 'MARCH'], 3))))


n = int(input())
s = [0] * 5
ans = 0
for i in range(n):
	x = list(input())[0]
	if x == 'M':
		s[0] += 1
	if x == 'A':
		s[1] += 1
	if x == 'R':
		s[2] += 1
	if x == 'C':
		s[3] += 1
	if x == 'H':
		s[4] += 1
for a in range(5):
	for b in range(a + 1, 5):
		for c in range(b + 1, 5):
			ans += s[a] * s[b] * s[c]
print(ans)


from itertools import combinations
from collections import Counter
s = 0
n = int(input())
l = Counter(list((input()[0] for _ in range(n))))
for (a, b, c) in combinations('MARCH', 3):
	s += l[a] * l[b] * l[c]
print(s)


from collections import *
d = Counter()
for _ in range(int(input())):
	d[input()[0]] += 1
import itertools as it
print(sum((d[s] * d[t] * d[r] for (s, t, r) in it.combinations('MARCH', 3))))


import sys
import itertools
input = sys.stdin.readline

def main():
	N = int(input())
	l = ['M', 'A', 'R', 'C', 'H']
	m = [0] * 5
	for _ in range(N):
		S = input()[:-1]
		Shead = S[0]
		for (i, s0) in enumerate(l):
			if Shead == s0:
				m[i] += 1
				break
	ll = []
	for (i, n) in enumerate(m):
		if n >= 1:
			ll.append(l[i])
	if len(ll) <= 2:
		print(0)
		return
	ans = 0
	for (i, j, k) in itertools.combinations(ll, 3):
		ans += m[l.index(i)] * m[l.index(j)] * m[l.index(k)]
	print(ans)

def __starting_point():
	main()
__starting_point()


from itertools import *
(n, *a) = open(0).read().split()
print(sum((p * q * r for (p, q, r) in combinations(map([i[0] for i in a].count, 'MARCH'), 3))))


from collections import Counter
n = int(input())
A = [input()[0] for i in range(n)]
A = Counter(A)
m = A['M']
a = A['A']
r = A['R']
c = A['C']
h = A['H']
print(m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h)


from collections import Counter
from itertools import combinations
N = int(input())
S = [input()[0] for _ in range(N)]
cnt = Counter(S)
ans = 0
for elem in combinations('MARCH', 3):
	ans += cnt[elem[0]] * cnt[elem[1]] * cnt[elem[2]]
print(ans)


n = int(input())
march = ['M', 'A', 'R', 'C', 'H']
cnt = [0] * 5
for i in range(n):
	inp = input()
	for j in march:
		if inp[0] == j:
			cnt[march.index(j)] += 1
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += cnt[i] * cnt[j] * cnt[k]
print(ans)


d = {t: 0 for t in 'MARCH'}
a = 0
for t in open(0).read().split():
	if t[0] in d:
		d[t[0]] += 1
for i in range(32):
	c = t = 1
	for (j, l) in enumerate(d.values()):
		if i >> j & 1:
			t *= l
			c += 1
	a += t * (c == 4)
print(a)


m = [0] * 5
for i in range(int(input())):
	try:
		m['MARCH'.index(input()[0])] += 1
	except:
		continue
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += m[i] * m[j] * m[k]
print(ans)


from collections import Counter
from itertools import combinations
n = int(input())
s = [list(input())[0] for _ in range(n)]
c = Counter(s)
cnt = 0
lst = list('MARCH')
lstcmb = combinations(lst, 3)
for k in lstcmb:
	cnt += c[k[0]] * c[k[1]] * c[k[2]]
print(cnt)


n = int(input())
cnt = [0] * 5
check = 'MARCH'
for i in range(n):
	s = input()
	for j in range(5):
		if s[0] == check[j]:
			cnt[j] += 1
			break
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += cnt[i] * cnt[j] * cnt[k]
print(ans)


from itertools import combinations as comb
n = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(n):
	try:
		d[input()[0]] += 1
	except:
		continue
c = 0
l = d.values()
for (i, j, k) in comb(l, 3):
	c += i * j * k
print(c)


n = int(input())
march = []
for i in range(n):
	x = input()
	march.append(x[0])
m = march.count('M')
a = march.count('A')
r = march.count('R')
c = march.count('C')
h = march.count('H')
ways = m * a * r + m * a * c + m * a * h + m * r * c + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h + m * r * h
print(ways)


import itertools
n = int(input())
ans = 0
set_m = set()
set_a = set()
set_r = set()
set_c = set()
set_h = set()
for i in range(n):
	s = input()
	if s[0] == 'M':
		set_m.add(s)
	if s[0] == 'A':
		set_a.add(s)
	if s[0] == 'R':
		set_r.add(s)
	if s[0] == 'C':
		set_c.add(s)
	if s[0] == 'H':
		set_h.add(s)
l_m = len(set_m)
l_a = len(set_a)
l_r = len(set_r)
l_c = len(set_c)
l_h = len(set_h)
l_l = [l_m, l_a, l_r, l_c, l_h]
comb_list = list(itertools.combinations(l_l, 3))
for i in range(len(comb_list)):
	ans += comb_list[i][0] * comb_list[i][1] * comb_list[i][2]
print(ans)


import itertools
N = int(input())
S = [input()[0] for T in range(N)]
MARCH = [S.count('M'), S.count('A'), S.count('R'), S.count('C'), S.count('H')]
Total = 0
for T in itertools.combinations(MARCH, 3):
	Total += T[0] * T[1] * T[2]
print(Total)


N = int(input())
S = [input()[0] for _ in range(N)]
C = [S.count(c) for c in 'MARCH']
print(C[0] * C[1] * C[2] + C[0] * C[1] * C[3] + C[0] * C[1] * C[4] + C[0] * C[2] * C[3] + C[0] * C[2] * C[4] + C[0] * C[3] * C[4] + C[1] * C[2] * C[3] + C[1] * C[2] * C[4] + C[1] * C[3] * C[4] + C[2] * C[3] * C[4])


n = int(input())
l = [0] * 5
m = 'MARCH'
for i in range(n):
	s = input()
	f = s[0]
	for i in range(5):
		if f == m[i]:
			l[i] += 1
			break
x = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			x += l[i] * l[j] * l[k]
print(x)


from collections import defaultdict
import itertools
n = int(input())
d = defaultdict(int)
for i in range(n):
	s = input()
	d[s[0]] += 1
l = ['M', 'A', 'R', 'C', 'H']
c = itertools.combinations(l, 3)
s = 0
for x in c:
	s += d[x[0]] * d[x[1]] * d[x[2]]
print(s)


N = int(input())
(c, MARCH) = ([0] * 5, ['M', 'A', 'R', 'C', 'H'])
for _ in range(N):
	ini = input()[0]
	if ini in MARCH:
		c[MARCH.index(ini)] += 1
print(c[0] * c[1] * (c[2] + c[3] + c[4]) + (c[0] + c[1]) * c[2] * (c[3] + c[4]) + (c[0] + c[1] + c[2]) * c[3] * c[4])


n = int(input())
S = set()
cnt = [0 for _ in range(5)]
for _ in range(n):
	s = input()
	if s in S:
		continue
	elif s[0] == 'M':
		cnt[0] += 1
	elif s[0] == 'A':
		cnt[1] += 1
	elif s[0] == 'R':
		cnt[2] += 1
	elif s[0] == 'C':
		cnt[3] += 1
	elif s[0] == 'H':
		cnt[4] += 1
	S.add(s)
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += cnt[i] * cnt[j] * cnt[k]
print(ans)


from itertools import combinations
import sys
n = int(sys.stdin.readline().rstrip())
s = [sys.stdin.readline().rstrip()[0] for _ in range(n)]
sum = 0
for (i, j, k) in combinations([s.count(l) for l in 'MARCH'], 3):
	sum += i * j * k
print(sum)


import collections
N = int(input())
lsname = []
for i in range(N):
	name = input()
	lsname.append(name[:1])
counterN = collections.Counter(lsname)
lskey = ['M', 'A', 'R', 'C', 'H']
lsnum = []
for i in lskey:
	if i in counterN.keys():
		lsnum.append(counterN[i])
ans = 0
lenN = len(lsnum)
for i in range(lenN - 2):
	for j in range(i + 1, lenN - 1):
		for k in range(j + 1, lenN):
			ans += lsnum[i] * lsnum[j] * lsnum[k]
print(ans)


N = int(input())
S = [input() for _ in range(N)]
cnt = [0] * N
cnt2 = []
flag = 0
if len(S) > 1:
	for i in range(N):
		if S[i][0] == 'M':
			cnt[0] += 1
		elif S[i][0] == 'A':
			cnt[1] += 1
		elif S[i][0] == 'R':
			cnt[2] += 1
		elif S[i][0] == 'C':
			cnt[3] += 1
		elif S[i][0] == 'H':
			cnt[4] += 1
for i in range(N):
	if cnt[i] != 0:
		cnt2.append(cnt[i])
import math
import itertools
ans = 0
for v in itertools.combinations(cnt2, 3):
	ans += v[0] * v[1] * v[2]
print(ans)


n = int(input())
ss = 'MARCH'
c = [0 for i in range(5)]
for i in range(n):
	s = input()
	for j in range(5):
		if s[0] == ss[j]:
			c[j] += 1
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += c[i] * c[j] * c[k]
print(ans)


from itertools import combinations
import numpy as np
N = int(input())
d = [0] * 5
for i in range(N):
	s = input()
	if s[0] == 'M':
		d[0] += 1
	if s[0] == 'A':
		d[1] += 1
	if s[0] == 'R':
		d[2] += 1
	if s[0] == 'C':
		d[3] += 1
	if s[0] == 'H':
		d[4] += 1
ans = 0
for lis in combinations(d, 3):
	ans += np.prod(lis)
print(ans)


from itertools import *
d = {}
g = d.get
for t in open(0).read().split():
	d[t[0]] = g(t[0], 0) + 1
print(sum((p * q * r for (p, q, r) in combinations([g(t, 0) for t in 'MARCH'], 3))))


import itertools
n = int(input())
s = []
c = 0
for i in range(n):
	s.append(input()[0])
seq = list(itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3))
for l in seq:
	c += s.count(l[0]) * s.count(l[1]) * s.count(l[2])
print(c)


import sys
from collections import Counter
sys.setrecursionlimit(10 ** 8)
ini = lambda : int(sys.stdin.readline())
inl = lambda : [int(x) for x in sys.stdin.readline().split()]
ins = lambda : sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print('\x1b[33m', *a, '\x1b[0m', **dict(file=sys.stderr, **kw))

def solve():
	n = ini()
	S = [ins() for _ in range(n)]
	c = Counter()
	M = 'MARCH'
	for x in S:
		if x[0] in M:
			c[x[0]] += 1
	ans = 0
	for i in range(5):
		for j in range(i):
			for k in range(j):
				ans += c[M[i]] * c[M[j]] * c[M[k]]
	return ans
print(solve())


from itertools import combinations
from collections import Counter
n = int(input())
C = Counter()
for i in range(n):
	C[input()[0]] += 1
print(sum((C[a] * C[b] * C[c] for (a, b, c) in combinations('MARCH', 3))))


(a, b, c, d, e) = (0, 0, 0, 0, 0)
for _ in [0] * int(input()):
	s = input()[0]
	if s == 'M':
		a += 1
	elif s == 'A':
		b += 1
	elif s == 'R':
		c += 1
	elif s == 'C':
		d += 1
	elif s == 'H':
		e += 1
print(a * b * (c + d + e) + (a + b) * (c * d + d * e + e * c) + c * d * e)


import itertools
n = int(input())
S = 'MARCH'
d = {s: 0 for s in S}
ans = 0
for i in range(n):
	f = input()[0]
	if f in S:
		d[f] += 1
for (x, y, z) in itertools.combinations(d.keys(), 3):
	ans += d[x] * d[y] * d[z]
print(ans)


import itertools as ite
N = int(input())
C = [0] * 6
J = 'MARCH'
for i in range(N):
	C[J.find(input()[0])] += 1
ans = 0
for (i, j, k) in list(ite.combinations(range(5), 3)):
	ans += C[i] * C[j] * C[k]
print(ans)


N = int(input())
dic = [0] * 128
for _ in range(N):
	dic[ord(input()[0])] += 1
(M, A, R, C, H) = [dic[ord(x)] for x in list('MARCH')]
print(M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H)


import itertools
N = int(input())
S = [input()[0] for i in range(N)]
march = ['M', 'A', 'R', 'C', 'H']
sum = 0
for c in list(itertools.combinations(march, 3)):
	sum += S.count(c[0]) * S.count(c[1]) * S.count(c[2])
print(sum)


N = int(input())
S = [input() for i in range(N)]
from collections import Counter
ctr = Counter([s[0] for s in S])
ans = 0
import itertools
for ptn in itertools.combinations('MARCH', 3):
	t = 1
	for c in ptn:
		t *= ctr[c]
	ans += t
print(ans)


one = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
n = int(input())
for i in range(n):
	c = input()[0]
	one[c] = one.get(c, 0) + 1
(m, a, r, c, h) = (one['M'], one['A'], one['R'], one['C'], one['H'])
print(m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h)


import collections
import itertools
n = int(input())
(l, s) = ([], [])
for i in range(n):
	a = input()
	if a[0] == 'M' or a[0] == 'A' or a[0] == 'R' or (a[0] == 'C') or (a[0] == 'H'):
		l.append(a[0])
		if s.count(a[0]) == 0:
			s.append(a[0])
l = collections.Counter(l)
ans = 0
for j in itertools.combinations(s, 3):
	ans += l[j[0]] * l[j[1]] * l[j[2]]
print(ans)


N = int(input())
S = [input() for i in range(N)]
MARCH_dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
MARCH_list = ['M', 'A', 'R', 'C', 'H']
for i in range(N):
	if S[i][0] in MARCH_list:
		MARCH_dic[S[i][0]] += 1
p_01 = MARCH_dic['M'] * MARCH_dic['A'] * MARCH_dic['R']
p_02 = MARCH_dic['M'] * MARCH_dic['A'] * MARCH_dic['C']
p_03 = MARCH_dic['M'] * MARCH_dic['A'] * MARCH_dic['H']
p_04 = MARCH_dic['M'] * MARCH_dic['R'] * MARCH_dic['C']
p_05 = MARCH_dic['M'] * MARCH_dic['R'] * MARCH_dic['H']
p_06 = MARCH_dic['M'] * MARCH_dic['C'] * MARCH_dic['H']
p_07 = MARCH_dic['A'] * MARCH_dic['R'] * MARCH_dic['C']
p_08 = MARCH_dic['A'] * MARCH_dic['R'] * MARCH_dic['H']
p_09 = MARCH_dic['A'] * MARCH_dic['C'] * MARCH_dic['H']
p_10 = MARCH_dic['R'] * MARCH_dic['C'] * MARCH_dic['H']
ans = 0
for i in range(10):
	ans += eval(f'p_{str(i + 1).zfill(2)}')
print(ans)


N = int(input())
S = [input()[:1] for _ in range(N)]
c = [S.count(s) for s in 'MARCH' if S.count(s)]
ans = 0
if len(c) > 2:
	ans += c[0] * c[1] * c[2]
if len(c) > 3:
	for i in c[3:]:
		for j in range(3):
			tmp = c[:3]
			tmp[j] = i
			ans += tmp[0] * tmp[1] * tmp[2]
if len(c) > 4:
	tmp = c[3:]
	for j in range(3):
		ans += tmp[0] * tmp[1] * c[j]
print(ans)


from itertools import combinations
(n, *S) = open(0).read().split()
n = int(n)
march = []
for c in 'MARCH':
	march.append(len([s for s in S if s[0] == c]))
ans = 0
for (a, b, c) in combinations(march, 3):
	ans += a * b * c
print(ans)


from itertools import combinations
n = int(input())
w = [0] * 5
march = 'MARCH'
for i in range(n):
	s = input()[0]
	if s in march:
		w[march.index(s)] += 1
print(sum(map(lambda a: a[0] * a[1] * a[2], combinations(w, 3))))


N = int(input())
d = {}
l = 'MARCH'
c = [0 for _ in range(5)]
for n in range(N):
	S = input()
	for n in range(len(l)):
		if l[n] == S[0]:
			c[n] += 1
ans = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += c[i] * c[j] * c[k]
print(ans)


N = int(input())
S = [input()[0] for _ in range(N)]
from collections import Counter
dic = Counter(S)
from itertools import combinations
result = 0
for (a, b, c) in combinations('MARCH', 3):
	result += dic[a] * dic[b] * dic[c]
print(result)


from collections import Counter
from itertools import combinations
n = int(input())
s = [input()[0] for _ in range(n)]
cnt = Counter(s)
ans = 0
for (a, b, c) in combinations('MARCH', 3):
	ans += cnt[a] * cnt[b] * cnt[c]
print(ans)


from itertools import combinations
from collections import defaultdict
d = defaultdict(int)
n = int(input())
for _ in range(n):
	d[input()[0]] += 1
ans = 0
for com in combinations('MARCH', 3):
	ans += d[com[0]] * d[com[1]] * d[com[2]]
print(ans)


import itertools
A = 'MARCH'
c = {a: 0 for a in A}
N = int(input())
for _ in range(N):
	S = input()
	if S[0] in A:
		c[S[0]] += 1
print(sum([c[cb[0]] * c[cb[1]] * c[cb[2]] for cb in itertools.combinations(A, 3)]))


from collections import Counter
from itertools import combinations, starmap
func = lambda x, y, z: x * y * z

def main():
	with open(0) as f:
		(N, *S) = f.read().split()
	S = [s[0] for s in S if s[0] in list('MARCH')]
	S = Counter(S)
	ans = sum(starmap(func, combinations(S.values(), 3)))
	print(ans)
main()


from itertools import combinations
n = int(input())
s = [input()[0] for _ in range(n)]
a = []
for i in ['M', 'A', 'R', 'C', 'H']:
	a += [s.count(i)]
ans = 0
for i in combinations(a, 3):
	ans += i[0] * i[1] * i[2]
print(ans)


from itertools import combinations
from collections import Counter
N = int(input())
S = Counter()
for i in range(N):
	S[input()[0]] += 1
tmp = []
for (a, b, c) in combinations('MARCH', 3):
	tmp.append(int(S[a] * S[b] * S[c]))
print(sum(tmp))


from itertools import combinations
n = int(input())
D = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for _ in range(n):
	s = input()[0]
	if s in D:
		D[s] += 1
print(sum([i * j * k for (i, j, k) in combinations(D.values(), 3)]))


import collections
import itertools
N = int(input())
S = [input() for _ in range(N)]
cnt = collections.Counter()
for s in S:
	cnt[s[0]] += 1
ans = 0
for (x, y, z) in itertools.combinations('MARCH', 3):
	ans += cnt[x] * cnt[y] * cnt[z]
print(ans)


from itertools import combinations as c
n = int(input())
l = [0] * 5
for i in range(n):
	s = input()
	s = s[0]
	if s in 'MARCH':
		l['MARCH'.index(s)] += 1
ans = 0
for (x, c, v) in c(range(5), 3):
	ans += l[x] * l[c] * l[v]
print(ans)


from itertools import combinations
(N, *S) = open(0).read().split()
MARCH = ('M', 'A', 'R', 'C', 'H')
cnt = {c: 0 for c in MARCH}
for s in S:
	if s[0] in MARCH:
		cnt[s[0]] += 1
print(sum((cnt[a] * cnt[b] * cnt[c] for (a, b, c) in combinations(MARCH, 3))))


from itertools import combinations
from functools import reduce
n = int(input())
x = [0 for _ in range(5)]
for _ in range(n):
	s = input()
	if s[0] == 'M':
		x[0] += 1
	if s[0] == 'A':
		x[1] += 1
	if s[0] == 'R':
		x[2] += 1
	if s[0] == 'C':
		x[3] += 1
	if s[0] == 'H':
		x[4] += 1

def f(a, b):
	return a * b
x = [n for n in x if n != 0]
ans = 0
for c in combinations(x, 3):
	ans += reduce(f, c)
print(ans)


n = int(input())
march = ['M', 'A', 'R', 'C', 'H']
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(n):
	s = input()
	if s[0] in march:
		d[s[0]] = d.get(s[0], 0) + 1
ans = 0
li = []
for i in d:
	for j in d:
		for k in d:
			if i != j and j != k and (k != i) and (not set([i, j, k]) in li):
				li.append(set([i, j, k]))
				ans += d[i] * d[j] * d[k]
print(ans)


from itertools import combinations

def main():
	s = [i[0] for i in open(0).read().split()[1:]]
	c = [s.count(i) for i in 'MARCH']
	a = sum((x * y * z for (x, y, z) in combinations(c, 3)))
	print(a)
main()


from itertools import combinations
N = int(input())
L = [input()[0] for _ in range(N)]
ans = sum((x * y * z for (x, y, z) in combinations([L.count(s) for s in 'MARCH'], 3)))
print(ans)


p = list('MARCH')
d = [0] * 5
n = int(input())
for i in range(n):
	r = input()
	q = r[0]
	if r[0] in p:
		d[p.index(r[0])] += 1
c = 0
for i in range(3):
	for j in range(i + 1, 4):
		for s in range(j + 1, 5):
			c += d[i] * d[j] * d[s]
print(c)


n = int(input())
s = 'MARCH'
d = {i: 0 for i in s}
for _ in range(n):
	f = input()[0]
	if f in s:
		d[f] += 1
ans = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += d[s[i]] * d[s[j]] * d[s[k]]
print(ans)


import collections
import itertools
n = int(input())
s = []
for _ in range(n):
	s.append(input())
s = [i[0] for i in s if i[0] in 'MARCH']
l = collections.Counter(s)
c = 0
for (i, j, k) in itertools.combinations(l.keys(), 3):
	c += l[i] * l[j] * l[k]
print(c)


from itertools import combinations
n = int(input())
s = list(map(lambda s: s[0], [input() for _ in range(n)]))
marchn = [s.count(c) for c in list('MARCH')]
ans = 0
for li in combinations(marchn, 3):
	ans += li[0] * li[1] * li[2]
print(ans)


n = int(input())
li = [0] * 5
for k in range(n):
	s = input()
	if s[0] == 'M':
		li[0] += 1
	elif s[0] == 'A':
		li[1] += 1
	elif s[0] == 'R':
		li[2] += 1
	elif s[0] == 'C':
		li[3] += 1
	elif s[0] == 'H':
		li[4] += 1
ans = 0
for i in range(2 ** 5):
	num = 1
	if str(bin(i)).count('1') == 3:
		for j in range(5):
			if i >> j & 1 == 1:
				num *= li[j]
		else:
			ans += num
print(ans)


(n, *s) = map(str, open(0).read().split())
a = [0] * 5
ans = 0
for i in s:
	if i[0] in 'MARCH':
		a['MARCH'.index(i[0])] += 1
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += a[i] * a[j] * a[k]
print(ans)


n = int(input())
L = [input()[0] for _ in range(n)]
L = [L.count(s) for s in 'MARCH']
a = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			a += L[i] * L[j] * L[k]
print(a)


n = int(input())
s = []
for _ in range(n):
	s.append(input()[0])
import collections
c = collections.Counter(s)
lis = [c['M'], c['A'], c['R'], c['C'], c['H']]
from itertools import *
ans = 0
for tmp in combinations(lis, 3):
	ans += tmp[0] * tmp[1] * tmp[2]
print(ans)


N = int(input())
S = 'MARCH'
dic = {s: 0 for s in S}
for _ in range(N):
	s = input()[0]
	if s in S:
		dic[s] += 1
print(sum([dic[a] * dic[b] * dic[c] for a in S for b in S for c in S if a < b < c]))


N = int(input())
C = [0] * 6
for _ in range(N):
	C['MARCH'.find(input()[0])] += 1
from itertools import *
D = list(combinations(C[:5], 3))
ans = 0
for (i, j, k) in D:
	ans += i * j * k
print(ans)


from collections import Counter
import itertools
N = int(input())
S = [input()[0] for _ in range(N)]
c = Counter(S)
print(sum((c[x] * c[y] * c[z] for (x, y, z) in itertools.combinations('MARCH', 3))))


n = int(input())
s = [input() for _ in [0] * n]
march = [0] * 5
for x in s:
	if x[0] in 'MARCH':
		march['MARCH'.index(x[0])] += 1
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += march[i] * march[j] * march[k]
print(ans)


from itertools import combinations as c
n = int(input())
l = [input() for _ in range(n)]
m = 'MARCH'
p = [0] * 5
r = 0
for s in l:
	for i in range(5):
		if s[0] == m[i]:
			p[i] += 1
for d in c(p, 3):
	r += d[0] * d[1] * d[2]
print(r)


n = int(input())
S = list(set([input() for _ in range(n)]))
name = [0] * 5
for s in S:
	if s[0] == 'M':
		name[0] += 1
	if s[0] == 'A':
		name[1] += 1
	if s[0] == 'R':
		name[2] += 1
	if s[0] == 'C':
		name[3] += 1
	if s[0] == 'H':
		name[4] += 1
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += name[i] * name[j] * name[k]
print(ans)


from collections import Counter

def __starting_point():
	N = int(input())
	C = Counter()
	march = ['M', 'A', 'R', 'C', 'H']
	for _ in range(N):
		s = input()
		if s[0] in march:
			C[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 += C[march[i]] * C[march[j]] * C[march[k]]
	print(ans)
__starting_point()


n = int(input())
l = [0, 0, 0, 0, 0]
for _ in range(n):
	s = input()
	if s[0] == 'M':
		l[0] += 1
	if s[0] == 'A':
		l[1] += 1
	if s[0] == 'R':
		l[2] += 1
	if s[0] == 'C':
		l[3] += 1
	if s[0] == 'H':
		l[4] += 1
ans = 0
for i in range(0, 5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += l[i] * l[j] * l[k]
print(ans)


from itertools import combinations
n = int(input())
s = [input() for _ in range(n)]
letters = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
to_check = combinations([i for i in 'MARCH'], 3)
for word in s:
	if word[0] in letters:
		letters[word[0]] += 1
count = 0
for i in to_check:
	count += letters[i[0]] * letters[i[1]] * letters[i[2]]
print(count)


import itertools
N = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for _ in range(N):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
a = list(itertools.combinations('MARCH', 3))
ans = 0
for l in a:
	ans += d[l[0]] * d[l[1]] * d[l[2]]
print(ans)


o = ord
d = [0] * 128
for t in open(0).read().split():
	d[o(t[0])] += 1
print(sum((d[o(p)] * d[o(q)] * d[o(r)] for (p, q, r) in __import__('itertools').combinations('MARCH', 3))))


n = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for _ in range(n):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
march = list('MARCH')
from itertools import combinations
ans = 0
for (a, b, c) in combinations(march, 3):
	ans += d[a] * d[b] * d[c]
print(ans)


import itertools
N = int(input())
S = [input()[0] for _ in range(N)]
S = [v for v in S if v in 'MARCH']
s = list(set(S))
c = 0
for v in itertools.combinations(s, 3):
	c += S.count(v[0]) * S.count(v[1]) * S.count(v[2])
print(c)


import itertools
N = int(input())
D = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
	s = input()
	if s[0] in D.keys():
		D[s[0]] += 1
ans = 0
for v in itertools.combinations(D.values(), 3):
	ans += v[0] * v[1] * v[2]
print(ans)


import itertools
n = int(input())
arr = [input()[0] for i in range(n)]
word = ['M', 'A', 'R', 'C', 'H']
ans = 0
con = list(itertools.combinations(word, 3))
for i in con:
	ans += arr.count(i[0]) * arr.count(i[1]) * arr.count(i[2])
print(ans)


import itertools
N = int(input())
l = [0] * 5
m = list('MARCH')
for i in range(N):
	S = input()
	if S[0] in m:
		l[m.index(S[0])] += 1
ans = 0
for i in list(itertools.combinations(l, 3)):
	m = 1
	for j in i:
		m *= j
	ans += m
print(ans)


from collections import Counter
from itertools import combinations
N = int(input())
Slist = [input() for _ in range(N)]
Sc = Counter([S[0] for S in Slist])
ans = 0
for (x, y, z) in combinations(list('MARCH'), 3):
	ans += Sc[x] * Sc[y] * Sc[z]
print(ans)


n = int(input())
names = [input()[0] for i in range(n)]
prefix = 'MARCH'
cnt = [names.count(c) for c in prefix]
ans = 0
for i in range(5):
	for j in range(i + 1, 5):
		for k in range(j + 1, 5):
			ans += cnt[i] * cnt[j] * cnt[k]
print(ans)


import sys
sys.setrecursionlimit(10 ** 7)

def I():
	return int(sys.stdin.readline().rstrip())

def MI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def LI2():
	return list(map(int, sys.stdin.readline().rstrip()))

def S():
	return sys.stdin.readline().rstrip()

def LS():
	return list(sys.stdin.readline().rstrip().split())

def LS2():
	return list(sys.stdin.readline().rstrip())
N = I()
(m, a, r, c, h) = (0, 0, 0, 0, 0)
for _ in range(N):
	s = S()
	x = s[0]
	if x == 'M':
		m += 1
	elif x == 'A':
		a += 1
	elif x == 'R':
		r += 1
	elif x == 'C':
		c += 1
	elif x == 'H':
		h += 1
print(m * a * (r + c + h) + m * r * (c + h) + m * c * h + a * r * (c + h) + a * c * h + r * c * h)


from collections import Counter
from itertools import combinations
S = [input() for _ in range(int(input()))]
C = Counter((s[0] for s in S))
march = [s for s in 'MARCH' if s in C]
ans = 0
for p in combinations(march, 3):
	ans += C[p[0]] * C[p[1]] * C[p[2]]
print(ans)


n = int(input())
s = [input()[0] for _ in range(n)]
c = [s.count('M'), s.count('A'), s.count('R'), s.count('C'), s.count('H')]
ans = c[0] * c[1] * c[2]
ans += c[0] * c[1] * c[3]
ans += c[0] * c[1] * c[4]
ans += c[0] * c[2] * c[3]
ans += c[0] * c[2] * c[4]
ans += c[0] * c[3] * c[4]
ans += c[1] * c[2] * c[3]
ans += c[1] * c[2] * c[4]
ans += c[1] * c[3] * c[4]
ans += c[2] * c[3] * c[4]
print(ans)


def idx_cmb(n, r):
	import itertools
	lst1 = [i for i in range(0, n)]
	lst = list(itertools.combinations(lst1, r))
	return lst

def main():
	n = int(input())
	s_lst = [str(input()) for _ in range(n)]
	march = [0] * 5
	for i in range(n):
		s = s_lst[i]
		if s[0] == 'M':
			march[0] += 1
		elif s[0] == 'A':
			march[1] += 1
		elif s[0] == 'R':
			march[2] += 1
		elif s[0] == 'C':
			march[3] += 1
		elif s[0] == 'H':
			march[4] += 1
	idx_lst = idx_cmb(5, 3)
	x = 0
	for i in range(len(idx_lst)):
		idx1 = idx_lst[i][0]
		idx2 = idx_lst[i][1]
		idx3 = idx_lst[i][2]
		number1 = march[idx1]
		number2 = march[idx2]
		number3 = march[idx3]
		x += number1 * number2 * number3
	print(x)

def __starting_point():
	main()
__starting_point()


import itertools
n = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(n):
	s = input()
	if s[0] in d:
		d[s[0]] += 1
ans = 0
for v in itertools.combinations(d, 3):
	ans += d[v[0]] * d[v[1]] * d[v[2]]
print(ans)


n = int(input())
s = []
c = []
ans = 0
for i in range(n):
	s.append(input()[0])
for x in 'MARCH':
	c.append(s.count(x))
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += c[i] * c[j] * c[k]
print(ans)


import itertools
n = int(input())
T = 'MARCH'
ct = [0 for _ in range(5)]
for _ in range(n):
	s = input()
	if s[0] not in T:
		continue
	ct[T.find(s[0])] += 1
ans = 0
for (x, y, z) in itertools.combinations(ct, 3):
	ans += x * y * z
print(ans)


def main():
	from itertools import combinations
	import sys
	pin = sys.stdin.readline
	pout = sys.stdout.write
	perr = sys.stderr.write
	N = int(pin())
	ans = 0
	d = [0] * 5
	for _ in [0] * N:
		S = pin()[:-1][0]
		if S == 'M':
			d[0] += 1
		elif S == 'A':
			d[1] += 1
		elif S == 'R':
			d[2] += 1
		elif S == 'C':
			d[3] += 1
		elif S == 'H':
			d[4] += 1
	c = list(combinations([0, 1, 2, 3, 4], 3))
	for i in c:
		cnt = 1
		for j in list(i):
			cnt *= d[j]
		ans += cnt
	print(ans)
	return
main()


import itertools
N = int(input())
key = 'MARCH'
cnt = [0] * 5
for i in range(N):
	S = input()
	for j in range(5):
		if S[0] == key[j]:
			cnt[j] += 1
ans = 0
for v in itertools.combinations(cnt, 3):
	ans += v[0] * v[1] * v[2]
print(ans)


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	L = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
	for i in range(N):
		S = input().rstrip()
		if S[0] in L:
			L[S[0]] += 1
	CNT = 0
	i = 0
	S = [0] * 5
	for (k, v) in L.items():
		S[i] = v
		i += 1
	ans = 0
	for p in range(3):
		for q in range(p + 1, 4):
			for r in range(q + 1, 5):
				ans += S[p] * S[q] * S[r]
	print(ans)

def __starting_point():
	main()
__starting_point()


from collections import Counter
from itertools import combinations
N = int(input())
S = [input()[0] for _ in range(N)]
cnt = Counter(S)
ans = 0
for (a, b, c) in combinations('MARCH', 3):
	ans += cnt[a] * cnt[b] * cnt[c]
print(ans)


import itertools
(*s,) = open(0)
print(sum((i * j * k for (i, j, k) in itertools.combinations([sum((t.startswith(l) for t in s)) for l in 'MARCH'], 3))))


from collections import Counter
from itertools import combinations as comb
N = int(input())
d = Counter()
for _ in range(N):
	s = input()
	d[s[0]] += 1
ans = 0
for (i, j, k) in comb(['M', 'A', 'R', 'C', 'H'], 3):
	ans += d[i] * d[j] * d[k]
print(ans)


import collections
import itertools
N = int(input())
S = [input() for _ in range(N)]
S = [s[0] for s in S if s[0] == 'M' or s[0] == 'A' or s[0] == 'R' or (s[0] == 'C') or (s[0] == 'H')]
cnt = collections.Counter(S)
comb = itertools.combinations(cnt.keys(), 3)
ans = 0
for (a, b, c) in comb:
	ans += cnt[a] * cnt[b] * cnt[c]
print(ans)


from itertools import combinations
input = open(0).read
Sn = [i[0] for i in input().split() if i[0] in 'MARCH']

def main():
	print(sum((x * y * z for (x, y, z) in combinations([Sn.count(s) for s in 'MARCH'], 3))))
	return
main()


import collections, itertools
n = int(input())
s = collections.Counter([input()[0] for _ in range(n)])
ls = list('MARCH')
t = 0
for i in itertools.combinations(ls, 3):
	t += s[i[0]] * s[i[1]] * s[i[2]]
print(t)


N = int(input())
M = 0
A = 0
R = 0
C = 0
H = 0
for i in range(N):
	S = input()
	s = S[0]
	if s == 'M':
		M += 1
	elif s == 'A':
		A += 1
	elif s == 'R':
		R += 1
	elif s == 'C':
		C += 1
	elif s == 'H':
		H += 1
ans = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H
print(ans)


from collections import defaultdict
import itertools
n = int(input())
r = defaultdict(int)
for i in range(n):
	r[input()[0]] += 1
ans = 0
for c in itertools.combinations(list('MARCH'), 3):
	a = 1
	for cc in c:
		a *= r[cc]
	ans += a
print(ans)


n = int(input())
s = [input()[0] for _ in range(n)]
cnt = [s.count(v) for v in ('M', 'A', 'R', 'C', 'H')]
ans = 0
for i in range(5):
	for j in range(i):
		for k in range(j):
			ans += cnt[i] * cnt[j] * cnt[k]
print(ans)


import itertools
n = int(input())
l = []
for i in range(n):
	l.append(input()[0])
c = []
ul = ['M', 'A', 'R', 'C', 'H']
for i in ul:
	c.append(l.count(i))
cc = itertools.combinations(c, 3)
ans = 0
for (i, j, k) in cc:
	ans += i * j * k
print(ans)


import itertools
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(n):
	s = input()
	for e in ['M', 'A', 'R', 'C', 'H']:
		if s[0] == e:
			d[e] += 1
sum_num = 0
l = ['M', 'A', 'R', 'C', 'H']
for (a, b, c) in itertools.combinations(l, 3):
	sum_num += d[a] * d[b] * d[c]
print(sum_num)


N = int(input())
dic = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
k = dic.keys()
for i in range(N):
	s = input()
	if s[0] in k:
		dic[s[0]] += 1
from itertools import combinations
ans = 0
for (p, q, r) in combinations(k, 3):
	ans += dic[p] * dic[q] * dic[r]
print(ans)


from itertools import combinations
n = int(input())
name = [0] * 5
march = ['M', 'A', 'R', 'C', 'H']
for i in range(n):
	s = input()
	if s[0] in march:
		name[march.index(s[0])] += 1
sm = 0
for (i, j, k) in list(combinations(name, 3)):
	sm += i * j * k
print(sm)


N = int(input())
Name = [input()[0] for _ in range(N)]
March = {x: Name.count(x) for x in 'MARCH' if Name.count(x) > 0}
import itertools
ans = 0
for (x, y, z) in itertools.combinations(March.values(), 3):
	ans += x * y * z
print(ans)


import itertools
N = int(input())
t = tuple('MARCH')
dic = {}
for _ in range(N):
	s = input()
	x = s[0]
	if x not in t:
		continue
	if x in dic:
		dic[x] += 1
	else:
		dic[x] = 1
count = [v for v in list(dic.values())]
if len(count) < 3:
	print(0)
	return
ans = 0
for (a, b, c) in itertools.combinations(count, 3):
	ans += a * b * c
print(ans)


n = int(input())
from collections import Counter
c = Counter()
for _ in range(n):
	s = input()[0]
	c[s] += 1
ans = 0
ans += c['M'] * c['A'] * c['R']
ans += c['M'] * c['A'] * c['C']
ans += c['M'] * c['A'] * c['H']
ans += c['M'] * c['R'] * c['C']
ans += c['M'] * c['R'] * c['H']
ans += c['M'] * c['C'] * c['H']
ans += c['A'] * c['R'] * c['C']
ans += c['A'] * c['R'] * c['H']
ans += c['A'] * c['C'] * c['H']
ans += c['R'] * c['C'] * c['H']
print(ans)


N = int(input())
A = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for i in range(N):
	s = input()
	if s[0] in A:
		A[s[0]] += 1
B = [A['M'], A['A'], A['R'], A['C'], A['H']]
ans = 0
for i in range(3):
	for j in range(i + 1, 4):
		for k in range(j + 1, 5):
			ans += B[i] * B[j] * B[k]
print(ans)


import itertools
import collections
n = int(input())
c = collections.Counter([input()[0] for i in range(n)])
s = [c[x] for x in 'MARCH']
cnt = 0
for x in itertools.combinations(s, 3):
	cnt += x[0] * x[1] * x[2]
print(cnt)