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: introductory

Starter code:

Solutions:
#!/usr/bin/env python3
import itertools

n = int(input())


data = [[] for i in range(5)]
# print(data)
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)


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=[input()[0] for _ in range(N)]
A=[S.count(c) for c in "MARCH"]
ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=A[i]*A[j]*A[k]
print(ans)


import itertools
n = int(input())
name = [0]*5
s = []
for i in range(n):
    st = input()
    if st[0] == 'M':
        name[0] += 1
    elif st[0] == 'A':
        name[1] += 1
    elif st[0] == 'R':
        name[2] += 1
    elif st[0] == 'C':
        name[3] += 1
    elif st[0] == 'H':
        name[4] += 1
    s.append(st)

ans = 0
for v in itertools.combinations(name, 3):
    # print(v)
    ans += v[0]*v[1]*v[2]

print(ans)

# -*- coding: utf-8 -*-

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)


from collections import Counter
import itertools

n = int(input())
s = [input()[0] for _ in range(n)]

cnt = Counter(s)
ans = 0
for x, y, z in itertools.combinations("MARCH", 3):
    ans += cnt[x] * cnt[y] * cnt[z]
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)

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

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):
      #print(i,j,k)
      tot += L[i]*L[k]*L[j]

#print(d)
print(tot)


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 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 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)


# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 14:49:47 2020

@author: liang
"""

"""
【組み合わせ生成】
    itertools.combinations(iterable, r)
【総積】
    numpy.prod(iterable)
"""
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)

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

for i in l:
    if i==0:l.remove(i)
total=len(l)
if total<3:ans=0
else:
    ans=0
    for i in range(0,total-2):
        for j in range(i+1,total-1):
            for k in range(j+1,total):
                ans+=l[i]*l[j]*l[k]
print(ans)

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)

import sys
input = sys.stdin.readline
from itertools import combinations


def read():
    N = int(input().strip())
    S = []
    for i in range(N):
        s = input().strip()
        S.append(s)
    return N, S


def solve(N, S):
    Z = [0 for i in range(26)]
    for s in S:
        a = s[0]
        Z[ord(a)-ord("A")] += 1
    ans = 0
    D = [Z[ord(a)-ord("A")] for a in "MARCH"]
    for i, j, k in combinations(D, r=3):
        ans += i * j * k
    return ans


def __starting_point():
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print(("%s" % str(outputs)))

__starting_point()

n=int(input())
dic={"M":0,"A":0,"R":0,"C":0,"H":0}
check=["M","A","R","C","H"]

for i in range(n):
  s=input()
  if s[0] in check:
    dic[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+=dic[check[i]]*dic[check[j]]*dic[check[k]]
      
print(ans)



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)

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 sys
import itertools
from collections import Counter
N = int(input())
name = []
for _ in range(N):
    a = input()
    name.append(a[0])
name = Counter(name)
kouho = []
kouho.append(name["M"])
kouho.append(name["A"])
kouho.append(name["R"])
kouho.append(name["C"])
kouho.append(name["H"])
name = []
for i in kouho:
    if i == 0:
        continue
    name.append(i)
total = sum(name)
seki = 1
for i in name:
    seki = seki*i
hikuseki = 1
for i in name:
    if i > 1:
        hikuseki = hikuseki*i

if len(name) < 3:
    print((0))
    return

seki = list(itertools.combinations(name, 3))
ans = 0
for i in seki:
    a, b, c = i
    ans += a*b*c
print(ans)


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

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())
m = [0] * 5
s = "MARCH"
for i in range(N):
    a = input()
    for j in range(5):
        if s[j] == a[0]:
            m[j] += 1

ans = 0

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += m[i] * m[j] * m[k]

print(ans)


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()

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)

import itertools
# import math
# from functools import reduce
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]


# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

#def make_divisors(n):
#    lower_divisors , upper_divisors = [], []
#    i = 1
#    while i*i <= n:
#        if n % i == 0:
#            lower_divisors.append(i)
#            if i != n // i:
#                upper_divisors.append(n//i)
#        i += 1
#    return lower_divisors + upper_divisors[::-1]

# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

# if gcd_list(A) > 1:
#     print("not coprime")
#     return

# 高速素因数分解準備
#MAXN = 10**6+10
#sieve = [i for i in range(MAXN+1)]
#p = 2
#while p*p <= MAXN:
#    if sieve[p] == p:
#        for q in range(2*p, MAXN+1, p):
#            if sieve[q] == q:
#                sieve[q] = p
#    p += 1

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)

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())
li=[0,0,0,0,0]
for i in range(N):
    S=input()
    if S[0]=="M":
        li[0]+=1
    if S[0]=="A":
        li[1]+=1
    if S[0]=="R":
        li[2]+=1
    if S[0]=="C":
        li[3]+=1
    if S[0]=="H":
        li[4]+=1
lim=0
for j in range(5):
    if li[j]!=0:
        lim+=1
temp=1   
li.sort(reverse=True)
ans=0
if lim==3:
    ans=li[0]*li[1]*li[2]
elif lim==4:
    lis=[[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
    for l in range(4):
        for m in range(3):
            temp*=li[lis[l][m]-1]
        ans+=temp
        temp=1
        
elif lim==5:
    lis=[[1,2,3],[1,2,4],[1,2,5],[1,3,4],[1,3,5],[1,4,5],[2,3,4],[2,3,5],[2,4,5],[3,4,5]]
    for l in range(10):
        for m in range(3):
            temp*=li[lis[l][m]-1]
        ans+=temp
        temp=1
        
else:
    ans=0

print(ans)


import math
"""
int(input())
map(int, input().split())
list(map(int, input().split()))
input()
input().split()
"""

n = int(input())
ans = 0
dp = [0,0,0,0,0]
for i in range(n):
    s = input()
    if (s[0]=='M'): dp[0]+=1
    elif (s[0]=='A'): dp[1]+=1
    elif (s[0]=='R'): dp[2]+=1
    elif (s[0]=='C'): dp[3]+=1
    elif (s[0]=='H'): dp[4]+=1
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += dp[i]*dp[j]*dp[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()

import itertools
from collections import Counter

N = int(input())
S = Counter([input()[0] for i in range(N)])
res = 0
for a, b, c in itertools.combinations("MARCH", 3):
    res += S[a] * S[b] * S[c]

print(res)


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)

#60 C - March
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)

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)

'''
Created on 2020/08/31

@author: harurun
'''
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()
    
    
    


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()

from itertools import combinations

n=int(input())
d={'M':0,'A':0,'R':0,'C':0,'H':0}
for i in range(n):
  s=input()
  if s[0]=='M':
    d['M']+=1
  if s[0]=='A':
    d['A']+=1
  if s[0]=='R':
    d['R']+=1
  if s[0]=='C':
    d['C']+=1
  if s[0]=='H':
    d['H']+=1

ans=0
for i,j,k in combinations('MARCH',3):
  ans+=d[i]*d[j]*d[k]

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)

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 ["M","A","R","C","H"]:
        D[s[0]]+=1

from itertools import combinations as com 
ans=0
A=list(D.values()) ; # print(A)
for l in com(list(range(5)), 3):
    ans+= A[l[0]]* A[l[1]] * A[l[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)

n=int(input())
m=0
a=0
r=0
c=0
h=0
for i in range(n):
    s=input()
    if s[0]=="M":
        m+=1
    if s[0]=="A":
        a+=1
    if s[0]=="R":
        r+=1
    if s[0]=="C":
        c+=1
    if s[0]=="H":
        h+=1
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 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)

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)

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())
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)

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)

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()
  if si[0] in c:
    c[si[0]] += 1
ans = sum(i*j*k for i,j,k in cmbs(list(c.values()),r=3))
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 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("\033[33m", *a, "\033[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())


n = int(input())
a = [0] * 5
for i in range(n):
  s = input()
  if s[0] == "M":
    a[0] += 1
  elif s[0] == "A":
    a[1] += 1
  elif s[0] == "R":
    a[2] += 1
  elif s[0] == "C":
    a[3] += 1
  elif s[0] == "H":
    a[4] += 1

res = 0
res += a[0] * a[1] * a[2]
res += a[0] * a[1] * a[3]
res += a[0] * a[1] * a[4]
res += a[0] * a[2] * a[3]
res += a[0] * a[2] * a[4]
res += a[0] * a[3] * a[4]
res += a[1] * a[2] * a[3]
res += a[1] * a[2] * a[4]
res += a[1] * a[3] * a[4]
res += a[2] * a[3] * a[4]
print(res)

from itertools import combinations

n = int(input())
S = [input() for _ in range(n)]
initials = ('M', 'A', 'R', 'C', 'H')
d = {}
for s in S:
  if s[0] in initials:
    d[s[0]] = d.get(s[0], 0) + 1

print(sum(d[x] * d[y] * d[z] for x, y, z in combinations(d.keys(), 3)))

from collections import Counter
from itertools import combinations
n = int(input())
s = [list(input())[0] for _ in range(n)]
c = Counter(s)
cnt = 0
listcmb = combinations("MARCH",3)

for k in listcmb:
    cnt += c[k[0]]*c[k[1]]*c[k[2]]
print(cnt)



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 itertools import combinations as cmbs
import sys
c = {"M":0,"A":0,"R":0,"C":0,"H":0}
sys.stdin.readline()
for si in sys.stdin:
    if si[0] in c:
        c[si[0]] += 1
ans = sum(i*j*k for i,j,k in cmbs(list(c.values()),r=3))
print(ans)


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
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=[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())
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)

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)


import itertools
 
n = int(input())
 
 
data = [[] for i in range(5)]
# print(data)
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)

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()

n=int(input())
k=[0]*5 #M-A-R-C-H
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)

import itertools
n = int(input())
march = dict()

a = "MARCH"
for i in range(5):
    march[a[i]] = 0

for i in range(n):
    s = input()
    if s[0] in march:
        march[s[0]] += 1

res = 0
for i in itertools.combinations("MARCH", 3):
    tmp = 1
    for j in i:
        tmp *= march[j]
    res += tmp

print(res)


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()[: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)

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))
    #print(C)
    #print(c)

    for a,b,c in itertools.combinations(c,3):
        #print(a,b,c)
        ans += a*b*c

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)

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)]))

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 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()
  if si[0] in c:
    c[si[0]] += 1
ans = 0
for i,j,k in cmbs(list(c.values()),r=3):
  t = i*j*k
  ans += t
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 = {}
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)

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())
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)

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


import itertools
n = int(input())  # nは入力回数
#num_list = [int(input()) for _ in range(n)]
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)

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(list(c.values()),r=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
import math
#import numpy as np
N = int(input())

first = "MARCH"

dic = {s:0 for s in first}

for _ in range(N):
    s = input()
    if s[0] in dic:
        dic[s[0]] += 1

t = []
for key in dic:
    if dic[key] > 0:
        t.append(dic[key])

if len(t) < 3:
    print((0))
else:
    tl = len(t)
    ans = 0
    for i in range(2 ** tl):
        cnt = []
        for j in range(tl):
            if (i >> j) & 1:
                cnt.append(j)

        if len(cnt) == 3:
            tans = 1
            for i in cnt:
                tans *= t[i]

            ans += tans
    
    print(ans)


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 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()

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)

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_l = [  input() for _ in range(n)  ]

name_d = ['M','A','R','C','H']
sub_s = {}
for d in name_d:                    
    sub_s[d] = 0

for s in s_l:
    if s[0] in name_d:
        sub_s[s[0]] += 1

ans = 0
memo = set()
for i in range(5):
    for j in range(5):
        for k in range(5):
            a,b,c = sorted([i, j, k])
            if a != b and a!=c and b!=c:
                key = str(a)+str(b)+str(c)
                if key not in memo:
                    ans +=sub_s[name_d[a]] * sub_s[name_d[b]] * sub_s[name_d[c]]
                    memo.add(key)
print(ans)

n = int(input())
s = []
for i in range(n):
    s.append(input()[0])

c = (
    s.count("M"),
    s.count("A"),
    s.count("R"),
    s.count("C"),
    s.count("H"),
)
from itertools import combinations
a = sum(x*y*z for x, y, z in combinations(c, 3))
print(a, flush=True)



from sys import stdin
rs = lambda : stdin.readline().strip()
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N = ri()
    d = {s: i for i, s in enumerate('MARCH')}
    l = [0] * 5
    for i in range(N):
        s = rs()[0]
        if s in d:
            l[d[s]] += 1
    ans = 0
    for i in range(3):
        for j in range(i + 1, 4):
            for k in range(j + 1, 5):
                ans += l[i] * l[j] * l[k]
    print(ans)




def __starting_point():
    main()

__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)

N = int(input())
S = []
ans = 0

for i in range(N):
    S.append(str(input()))

S = list(set(S))
# print(S)
name = [0 for i in range(5)]

for j in range(len(S)):
    t = str(S[j])
    if t[0] == "M":
        name[0] += 1
    elif t[0] == "A":
        name[1] += 1
    elif t[0] == "R":
        name[2] += 1
    elif t[0] == "C":
        name[3] += 1
    elif t[0] == "H":
        name[4] += 1
# print(name)

for x in range(5):
    for y in range(5):
        if x == y:
            break
        for z in range(5):
            if x == z or y == z:
                break
            if name[x]*name[y]*name[z] > 0:
                ans += name[x]*name[y]*name[z]

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)

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)


import itertools
n = int(input())
num = [0]*5
name = ['M','A','R','C','H']
for _ in range(n):
    s = str(input())
    for i in range(5):
        if s[0] == name[i]:
            num[i] += 1
            break
num = [k for k in num if k != 0]
c = num.count(0)
if 2 <= c:
    print(0)
else:
    d = 0
    for h,j,l in itertools.combinations(num,3):
        d += (h*j*l)
    print(d)

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 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)

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)

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

#
# abc089 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
ZZ
ZZZ
Z
ZZZZZZZZZZ"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO"""
        output = """7"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    S = [input() for _ in range(N)]

    C = [0]*5
    for s in S:
        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

    ans = 0
    for i, c1 in enumerate(C):
        for j, c2 in enumerate(C[i+1:], i+1):
            for c3 in C[j+1:]:
                ans += c1*c2*c3

    print(ans)


def __starting_point():
    # unittest.main()
    resolve()

__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)


n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for _ in range(n):
    s = str(input())
    if s[0] == "M":
        m += 1
    elif s[0] == "A":
        a += 1
    elif s[0] == "R":
        r += 1
    elif s[0] == "C":
        c += 1
    elif s[0] == "H":
        h += 1

#print(m,a,r,c,h)
ans = m*(a*r+a*c+a*h+r*c+r*h+c*h)+a*(r*c+r*h+c*h)+r*c*h
print(ans)