Problem:
 Score : 300 points    Problem Statement 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 1 5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI      Sample Output 1 2  We can choose three people with the following names:    MASHIKE , RUMOI , HABORO    MASHIKE , RUMOI , HOROKANAI    Thus, we have two ways.       Sample Input 2 4
ZZ
ZZZ
Z
ZZZZZZZZZZ      Sample Output 2 0  Note that there may be no ways to choose three people so that the given conditions are met.       Sample Input 3 5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO      Sample Output 3 7

Solution (Python):
import sys
import itertools

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    march = [0]*5
    for _ in range(n):
        s = input()[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
    ans = 0
    for idx in itertools.combinations([0, 1, 2, 3, 4], 3):
        ans += march[idx[0]] * march[idx[1]] * march[idx[2]]
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
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)

Solution (Python):
from itertools import combinations
n=int(input())
dp=[0]*5
for i in range(n):
  s=input()
  if s[0]=="M":dp[0]+=1
  if s[0]=="A":dp[1]+=1
  if s[0]=="R":dp[2]+=1
  if s[0]=="C":dp[3]+=1
  if s[0]=="H":dp[4]+=1
ans=0
for a,b,c in combinations(dp,3):
  ans+=a*b*c
print(ans)

Solution (Python):
import itertools

N = int(input())

dic = {"M":{},"A":{},"R":{},"C":{},"H":{}}

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

ans = 0
for i in itertools.combinations(["M","A","R","C","H"],3):
    ans+= len(dic[i[0]])*len(dic[i[1]])*len(dic[i[2]])

print(ans)

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

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]

march = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for name in s:
    if name[0] in march.keys():
        march[name[0]] += 1



ans = march['M']*march['A']*march['R']
ans += march['M']*march['A']*march['C']
ans += march['M']*march['A']*march['H']
ans += march['M']*march['R']*march['C']
ans += march['M']*march['R']*march['H']
ans += march['M']*march['C']*march['H']


ans += march['A']*march['R']*march['C']
ans += march['A']*march['R']*march['H']
ans += march['A']*march['C']*march['H']

ans += march['R']*march['C']*march['H']

print(ans)

Solution (Python):
from collections import Counter 
from itertools import combinations
n=int(input())
s=[]
count=0
for _ in range(n):
    si=list(input())
    if si[0]=="M" or si[0]=="R" or si[0]=="A" or si[0]=="C" or si[0]=="H":

        s.append(si[0])
s_counter=Counter(s)
s_key=s_counter.keys()
if len(s_key)>=3:
    for i,j,k in combinations(s_key,3):
        count+=s_counter[i]*s_counter[j]*s_counter[k]
print(count)

Solution (Python):
import itertools

n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
d = []
for i in range(5):
    d.append(i)
p_list = list(itertools.combinations(d, 3))

for i in range(n):
    name = input()
    if name[0] == 'M':
        m +=1
    elif name[0] == 'A':
        a +=1
    elif name[0] == 'R':
        r +=1
    elif name[0] == 'C':
        c +=1
    elif name[0] == 'H':
        h +=1
con = [m,a,r,c,h]
ans = 0
for i in range(len(p_list)):
    ans += con[p_list[i][0]] * con[p_list[i][1]] * con[p_list[i][2]]
    
print(ans)

Solution (Python):
from itertools import combinations

N=int(input())
P={"M","A","R","C","H"}
X={x:0 for x in P}

for _ in range(N):
    S=input()
    if S[0] in P:
        X[S[0]]+=1

K=0
for (a,b,c) in combinations(P,3):
    K+=X[a]*X[b]*X[c]
print(K)

Solution (Python):
from itertools import permutations
S = [0] * 5
B = [False, False, True, True, True]
N = int(input())
for _ in range(N):
    s = input()
    if s[0] == 'M':
        S[0] += 1
    elif s[0] == 'A':
        S[1] += 1
    elif s[0] == 'R':
        S[2] += 1
    elif s[0] == 'C':
        S[3] += 1
    elif s[0] == 'H':
        S[4] += 1
res = 0
for p in set(permutations(B)):
    t = 1
    for i in range(5):
        if p[i]:
            t *= S[i]
    res += t
print(res)

Solution (Python):
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)]))

Solution (Python):
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)

Solution (Python):

import collections
N = int(input())
M = []
for i in range(N):
    c = input()[0]
    if c == 'M' or c == 'A' or c == 'R' or c == 'C' or c == 'H':
        M.append(c)
C = collections.Counter(M)
ans = 0
march = list('MARCH')
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += C[march[i]]*C[march[j]]*C[march[k]]
print(ans)

Solution (Python):
from itertools import *
N = int(input())
D = {"M":0,"A":0,"R":0,"C":0,"H":0}

for n in range(N):
  s = input()
  if s[0] in "MARCH":
    D[s[0]]+=1

print(sum(a*b*c for a,b,c in combinations(D.values(),3)))

Solution (Python):
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)))

Solution (Python):
from itertools import *
N = int(input())
S = [input() for n in range(N)]
D = {"M":0,"A":0,"R":0,"C":0,"H":0}
ans = 0

for s in S:
  if s[0] in "MARCH":
    D[s[0]]+=1

for a,b,c in combinations(D.values(),3):
  ans+=a*b*c

print(ans)

Solution (Python):
import itertools
n = int(input())
s = [input()[0] for i in range(n)]

c = [s.count(i) for i in 'MARCH']
ans = sum(c[i]*c[j]*c[k] for i,j,k in itertools.combinations(range(5), 3))
print(ans)

Solution (Python):

import itertools
import sys
n = int(input())
s = [input() for i in range(n)]
'''
1.
M,A,R,C,Hから始まる名前を抽出する
2.
MARCHの5文字から3文字選ぶ
3.
選んだ文字ごとに、人数の掛け算を行う
'''
m = 0
a = 0
r = 0
c = 0
h = 0
for si in s:
    if si[0] == 'M':
        m += 1
    elif si[0] == 'A':
        a += 1
    elif si[0] == 'R':
        r += 1
    elif si[0] == 'C':
        c += 1
    elif si[0] == 'H':
        h += 1
if m == 0 and a == 0 and r == 0 and c == 0 and h == 0:
    print(0)
else:
    p = itertools.combinations(['M','A','R','C','H'], 3)
    ans = 0
    for i in p:
        ans_ = 1
        if 'M' in i:
            ans_ *= m
        if 'A' in i:
            ans_ *= a
        if 'R' in i:
            ans_ *= r
        if 'C' in i:
            ans_ *= c
        if 'H' in i:
            ans_ *= h
        ans += ans_
    print(ans)

Solution (Python):
from collections import Counter
import itertools

n = int(input())
s = [input()[:1] for _ in range(n)]
s = Counter([i for i in s if i in ['M', 'A', 'R', 'C', 'H']])

li = list(itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3))

if len(s)<3:
    print(0)
    exit()

ans = 0
for i, j, k in li:
    ans += s[i]*s[j]*s[k]
print(ans)

Solution (Python):
from collections import Counter
N = int(input())

march = ("M", "A", "R", "C", "H")
cnt = Counter()
for _ in range(N):
    S = input()
    if S[0] in march:
        cnt[S[0]] += 1

res = 0

for m in range(2):
    for a in range(2):
        for r in range(2):
            for c in range(2):
                for h in range(2):
                    if m+a+r+c+h == 3:
                        x = 1
                        if m:
                            x *= cnt["M"]
                        if a:
                            x *= cnt["A"]
                        if r:
                            x *= cnt["R"]
                        if c:
                            x *= cnt["C"]
                        if h:
                            x *= cnt["H"]
                        res += x

print(res)

Solution (Python):
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)))

Solution (Python):
import itertools
from collections import Counter
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)

Solution (Python):
n = int(input())
c = {s: 0 for s in 'MARCH'}
for i in range(n):
    s = input()[0]
    if s in 'MARCH':
        c[s]+=1

c = [v for k, v in c.items()]

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)

Solution (Python):
def resolve():
    '''
    code here
    '''
    import collections
    import itertools
    N = int(input())
    Ss = [input()[0] for _ in range(N)]

    march_letter = [item for item in Ss if item in ['M', 'A', 'R', 'C', 'H']]
    march_cnt = collections.Counter(march_letter)

    if len(march_cnt) < 3:
        res = 0
    else:
        res_list = itertools.combinations(march_cnt.values(),3)

        res = 0
        for element in res_list:
            res += element[0]*element[1]*element[2]
    print(res)

if __name__ == "__main__":
    resolve()

Solution (Python):
def resolve():
    '''
    code here
    '''
    import collections
    import itertools
    import numpy as np
    N = int(input())
    Ss = [input()[0] for _ in range(N)]

    march_letter = [item for item in Ss if item in ['M', 'A', 'R', 'C', 'H']]
    march_cnt = collections.Counter(march_letter)

    if len(march_cnt) < 3:
        res = 0
    else:
        res_list = itertools.combinations(march_cnt.values(),3)

        res = 0
        for element in res_list:
            res += np.prod(np.array(element))
    print(res)

if __name__ == "__main__":
    resolve()

Solution (Python):
n = int(input())
li = [0]*5
for i 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
total = li[0]*li[1]*li[2] + li[0]*li[1]*li[3] + li[0]*li[1]*li[4] + li[0]*li[2]*li[3] + li[0]*li[2]*li[4] + li[0]*li[3]*li[4] + li[1]*li[2]*li[3] + li[1]*li[2]*li[4] + li[1]*li[3]*li[4] + li[2]*li[3]*li[4]
print(total)

Solution (Python):






import itertools





N = int(input())
S = {}
S["M"] = 0
S["A"] = 0
S["R"] = 0
S["C"] = 0
S["H"] = 0
for _ in range(N):
    tmp = input()
    if tmp[0] == "M":
        S["M"] += 1
    elif tmp[0] == "A":
        S["A"] += 1
    elif tmp[0] == "R":
        S["R"] += 1
    elif tmp[0] == "C":
        S["C"] += 1
    elif tmp[0] == "H":
        S["H"] += 1





ans = 0
for myset in list(itertools.combinations("MARCH",3)):
    ans += S[myset[0]]*S[myset[1]]*S[myset[2]]
print(ans)

Solution (Python):
n=int(input())



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

Solution (Python):
from itertools import combinations
n = int(input())
march = [0 for _ in range(5)]
for i in range(n):
    s = input()

    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
ans = 0
for i in combinations(range(5), 3):
    ans += march[i[0]] * march[i[1]] * march[i[2]]
print(ans)

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

ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      if 1<=l[i] and 1<=l[j] and 1<=l[k]:
        ans+=l[i]*l[j]*l[k]
print(ans)

Solution (Python):
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)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
name = [s() for i in range(n)]
m = [i for i in name if i.startswith("M")]
a = [i for i in name if i.startswith("A")]
r = [i for i in name if i.startswith("R")]
c = [i for i in name if i.startswith("C")]
h = [i for i in name if i.startswith("H")]
ml,al,rl,cl,hl = len(m),len(a),len(r),len(c),len(h)

ans = ml*al*rl + ml*al*cl + ml*al*hl +ml*rl*cl + ml*rl*hl + ml*cl*hl + al*cl*hl + al*rl*cl + al*rl*hl + rl*cl*hl

print(ans)

Solution (Python):
N = int(input())
S = [0]*5
D = {"M": 0, "A": 1, "R": 2, "C": 3, "H": 4}
for i in range(N):
  name = input()
  if name[0] in "MARCH":
    S[D[name[0]]] += 1
ans = 0
for i in range(0, 3):
  for j in range(i+1, 4):
    for k in range(j+1, 5):
      ans += S[i]*S[j]*S[k]
print(ans)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd





def solve():
    n = int(input())
    cc = ['M', 'A', 'R', 'C', 'H']
    cnt = defaultdict(int)
    for _ in range(n):
        s = input()
        if s[0] in cc:
            cnt[s[0]] += 1

    ans = 0
    from itertools import combinations
    kc = list(cnt.keys())
    for a, b, c in combinations(kc, 3):
        ans += cnt[a] * cnt[b] * cnt[c] 
    print(ans)
    
t = 1

for case in range(1,t+1):
    ans = solve()


"""

abc

"""

Solution (Python):
n=int(input())
march="MARCH"
c=[0 for _ in range(5)]
for i in range(n):
    s=str(input())
    for j in range(5):
        if s[0]==march[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)

Solution (Python):
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)

Solution (Python):
def main():
    n = int(input())
    S= []
    from collections import defaultdict
    import itertools
    D = defaultdict(int)
    for _ in range(n):
        s = input()
        D[s[0]] += 1

    L = ['M','A','R','C','H']
    ans = 0
    for p in list(itertools.combinations(L,3)):
        t = 1
        for i in p:
            t *= D[i]
        ans += t
    print(ans)

main()

Solution (Python):
N = int(input())
cnt_li = [0, 0, 0, 0, 0]
comb = [
    [0, 1, 2],
    [0, 1, 3],
    [0, 1, 4],
    [0, 2, 3],
    [0, 2, 4],
    [0, 3, 4],
    [1, 2, 3],
    [1, 2, 4],
    [1, 3, 4],
    [2, 3, 4],
]
for _ in range(N):
    s = input()
    if s[0] == 'M':
        cnt_li[0] += 1
    if s[0] == 'A':
        cnt_li[1] += 1
    if s[0] == 'R':
        cnt_li[2] += 1
    if s[0] == 'C':
        cnt_li[3] += 1
    if s[0] == 'H':
        cnt_li[4] += 1
ans = 0
for i in range(len(comb)):
    one, two, three = comb[i]
    mid = cnt_li[one] * cnt_li[two] * cnt_li[three]
    ans += mid
print(ans)

Solution (Python):
from itertools import combinations

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

ans = 0
for a, b, c in list(combinations(d.keys(), 3)):
    ans += (d[a] * d[b] * d[c])

print(ans)

Solution (Python):


n = int(input())
d = {}
dd = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for _ in range(n):
    s = input()
    if s[0] in list("MARCH") and s not in d:
        d[s] = True
        dd[s[0]] += 1

ans = 0
ans += dd["M"] * dd["A"] * dd["R"]
ans += dd["M"] * dd["A"] * dd["C"]
ans += dd["M"] * dd["A"] * dd["H"]
ans += dd["M"] * dd["R"] * dd["C"]
ans += dd["M"] * dd["R"] * dd["H"]
ans += dd["M"] * dd["C"] * dd["H"]
ans += dd["A"] * dd["R"] * dd["C"]
ans += dd["A"] * dd["R"] * dd["H"]
ans += dd["A"] * dd["C"] * dd["H"]
ans += dd["R"] * dd["C"] * dd["H"]
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
n=int(input())

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

Solution (Python):
import math

import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    d = defaultdict(int)
    for _ in range(n):
        si = input()
        d[si[0]] += 1
    dn = {0:"M",1:"A",2:"R",3:"C",4:"H"}
    ans = 0
    for j in itertools.combinations(range(5),3):
        ans += d[dn[j[0]]]*d[dn[j[1]]]*d[dn[j[2]]]
    print(ans)
    return None

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

l=[0]*5
n=int(input())
for i 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 q in list(itertools.combinations([0,1,2,3,4], 3)):
    c=1
    for i in q:
        c*=l[i]
    ans+=c
print(ans)

Solution (Python):
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

d = defaultdict(int)
n = readInt()
for c in [input() for i in range(n)]:
	d[c[0]]+=1
tar = [d["M"],d["A"],d["R"],d["C"],d["H"]]
ans = 0
for a in itertools.combinations(tar,3):
	ans+=a[0]*a[1]*a[2]

print(ans)

Solution (Python):
import sys
from itertools import combinations
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
    for _ in range(n):
        c = input()
        if c[0] in d: d[c[0]] += 1
    
    ans = 0
    for a, b, c in combinations(['M', 'A', 'R', 'C', 'H'], 3):
        ans += d[a] * d[b] * d[c]
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from itertools import combinations

N = INT()
march = {}

for ini in "MARCH":
    march[ini] = 0
    
for _ in range(N):
    s = input()
    
    if s[0] in "MARCH":
        march[s[0]] += 1

ans = 0

for comb in combinations(march.values(), 3):
    tmp = 1
    for c in comb:
        tmp *= c
    
    ans += tmp
    
print(ans)

Solution (Python):
import itertools

N = int(input())
count = [0, 0, 0, 0, 0]
for _ in range(N):
    l = input()[0]
    if l == 'M':
        count[0] += 1
    elif l == 'A':
        count[1] += 1
    elif l == 'R':
        count[2] += 1
    elif l == 'C':
        count[3] += 1
    elif l == 'H':
        count[4] += 1
ans = 0
for c in itertools.combinations(count, 3):
    ans += c[0]*c[1]*c[2]

print(ans)

Solution (Python):
N=int(input())
S_dict={'M':0,'A':0,'R':0,'C':0,'H':0}

for n in range(N):
    S = list(input())[0]
    try:
        S_dict[S]+=1
    except:
        pass
S_dict

from itertools import combinations
ans=0
for c_ in combinations(S_dict.keys(),3):
    ans+=S_dict[c_[0]]*S_dict[c_[1]]*S_dict[c_[2]]
print(ans)

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
c = collections.Counter([rr()[0] for _ in range(n)])
d = [v for k, v in c.items() if k in 'MARCH']
ans = 0
if len(d) >= 3:
    for lis in itertools.combinations(d, 3):
        a, b, c = lis
        ans += a*b*c
    print(ans)
else:
    print(0)

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

Solution (Python):
N = int(input())
from collections import defaultdict
dic = defaultdict(int)
for _ in range(N):
    s = input()
    dic[s[0]]+= 1
print(dic['M']*dic['A']*dic['R']+dic['M']*dic['A']*dic['C']+dic['M']*dic['A']*dic['H']+dic['M']*dic['C']*dic['R']+dic['M']*dic['H']*dic['R']+dic['M']*dic['C']*dic['H']+dic['C']*dic['A']*dic['R']+dic['H']*dic['A']*dic['R']+dic['C']*dic['H']*dic['R']+dic['C']*dic['A']*dic['H'])

Solution (Python):
from collections import Counter
from itertools import combinations
n = int(input())
s = []
for _ in range(n):
  t = input()[0]
  if t in {"M","A","R","C","H"}:
    s.append(t)

count = Counter(s)
if len(count) < 3:
  print(0)
  exit()

nums = []
for i in count.values():nums.append(i)

ans = 0
for i in combinations(nums, 3):
  ans += i[0]*i[1]*i[2]
print(ans)

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

Solution (Python):
N = int(input())
m, a, r, c, h = 0, 0, 0, 0, 0
for i 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
    
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)

Solution (Python):
from functools import reduce
from operator import mul
from itertools import combinations
n = int(input())
cnt = [0]*5
for _ in range(n):
    s = input()
    if s[0] not in 'MARCH':
        continue
    i = 'MARCH'.index(s[0])
    cnt[i] += 1


ans = 0
for subset in combinations(range(5), 3):
    ans += reduce(mul, [cnt[i] for i in subset])

print(ans)

Solution (Python):
M = ['M', 'A', 'R', 'C', 'H']
m = [0]*5
result = 0
n = int(input())
for i in range(n):
    name = input()[0]
    if name in M:
        index = M.index(name)
        m[index] += 1

for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            result += m[i]*m[j]*m[k]
print(result)

Solution (Python):
import itertools
N = int(input())
dic = [0 for _ in range(5)]
for i in range(N):
    S = input()
    data = S[0]
    if data == "M":  dic[0] += 1
    if data == "A":  dic[1] += 1
    if data == "R":  dic[2] += 1
    if data == "C":  dic[3] += 1
    if data == "H":  dic[4] += 1
    
a = range(5)
comb = list(itertools.combinations(a, 3))

ans = 0
for c in comb:
    ans += dic[c[0]] * dic[c[1]] * dic[c[2]]
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
s = [str(input()) for _ in range(n)]
count = [0]*5

for i in range(n):
    if s[i][0] == "M":
        count[0] += 1
    elif s[i][0] == "A":
        count[1] += 1
    elif s[i][0] == "R":
        count[2] += 1
    elif s[i][0] == "C":
        count[3] += 1
    elif s[i][0] == "H":
        count[4] += 1
ans = 0
ans += count[0]*count[1]*count[2]
ans += count[0]*count[1]*count[3]
ans += count[0]*count[1]*count[4]
ans += count[0]*count[2]*count[3]
ans += count[0]*count[2]*count[4]
ans += count[0]*count[3]*count[4]
ans += count[1]*count[2]*count[3]
ans += count[1]*count[2]*count[4]
ans += count[1]*count[3]*count[4]
ans += count[2]*count[3]*count[4]
print(ans)

Solution (Python):
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
    elif s[0]=="A":
        a+=1
    elif s[0]=="R":
        r+=1
    elif s[0]=="C":
        c+=1
    elif s[0]=="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)

Solution (Python):
n=int(input())
d={'M':0,'A':0,'R':0,'C':0,'H':0}
ans=0
for _ in range(n):
	i=input()
	try:
		d[i[0]]+=1
	except:
		pass
ans+=d['M']*d['A']*d['R']
ans+=d['M']*d['A']*d['C']
ans+=d['M']*d['A']*d['H']
ans+=d['M']*d['C']*d['H']
ans+=d['M']*d['R']*d['H']
ans+=d['A']*d['R']*d['C']
ans+=d['A']*d['R']*d['H']
ans+=d['A']*d['C']*d['H']
ans+=d['R']*d['C']*d['H']
ans+=d['M']*d['C']*d['R']
print(ans)

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect

sys.setrecursionlimit(10**6)
def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


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


def C(line):
    return [sys.stdin.readline() for _ in range(line)]

def nck(n, k, mod):
    bunbo = bunshi = 1
    for i in range(k):
        bunshi = (bunshi * (n-i)) % mod
        bunbo = (bunbo * (i+1)) % mod
    return (bunshi * pow(bunbo, mod-2, mod)) % mod

N = z()
s = []
M,A,R,C,H = 0, 0, 0, 0, 0
for i in range(N):
    tmp = S()
    if (tmp[0] == 'M'):
        M+=1
    elif (tmp[0] == 'A'):
        A+=1
    elif (tmp[0] == 'R'):
        R+=1
    elif (tmp[0] == 'C'):
        C+=1
    elif (tmp[0] == '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*C*H + R*C*H+ A*R*H
print(ans)

Solution (Python):
import sys

n=int(input())
if n<3:
  print(0)
  sys.exit()

m,a,r,c,h = 0,0,0,0,0

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

l=[m,a,r,c,h]


ans=0
for i in range(len(l)):
  for j in range(i+1,len(l)):
    for k in range(j+1,len(l)):
      ans+=l[i]*l[j]*l[k]

print(ans)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]

name_cnt = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for s_i in s:
    if s_i[0] in name_cnt.keys():
        name_cnt[s_i[0]] += 1

name_set = set()
name_chars = list(name_cnt.keys())

ans = 0
for i in range(0, 5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            ans += name_cnt[name_chars[i]] * name_cnt[name_chars[j]] * name_cnt[name_chars[k]]
print(ans)

Solution (Python):
from itertools import combinations

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

d = dict()
for name in s:
    if name[0] not in d:
        d[name[0]] = 1
    else:
        d[name[0]] += 1

res = 0
for v in combinations(['M', 'A', 'R', 'C', 'H'], 3):
    if v[0] in d and v[1] in d and v[2] in d:
        res += d[v[0]] * d[v[1]] * d[v[2]]

print(res)

Solution (Python):
from itertools import combinations

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

d = dict()
for name in s:
    if name[0] not in d:
        d[name[0]] = 1
    else:
        d[name[0]] += 1

res = 0
for v in list(combinations(['M', 'A', 'R', 'C', 'H'], 3)):
    if v[0] in d and v[1] in d and v[2] in d:
        res += d[v[0]] * d[v[1]] * d[v[2]]

print(res)

Solution (Python):
from collections import Counter
n = int(input())

ch = ['M', 'A', 'R', 'C', 'H']
c = Counter([])
c['M'] = 0
c['A'] = 0
c['R'] = 0
c['C'] = 0
c['H'] = 0
for i in range(n):
    s = str(input())
    if s[0] in ch:
        c[s[0]] += 1
        
cnt = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            
            cnt += c.most_common()[i][1] * \
                c.most_common()[j][1]*c.most_common()[k][1]
print(cnt)

Solution (Python):
N=int(input())
M=[]
A=[]
R=[]
C=[]
H=[]

for i in range(N):
    tmp=input()
    if tmp[0]=="M":
        M.append(tmp)
    elif tmp[0]=="A":
        A.append(tmp)
    elif tmp[0]=="R":
        R.append(tmp)
    elif tmp[0]=="C":
        C.append(tmp)
    elif tmp[0]=="H":
        H.append(tmp)

m=len(M)
a=len(A)
r=len(R)
c=len(C)
h=len(H)

if len(M)+len(A)+len(R)+len(C)+len(H)<=2:
    print(0)
else:
    print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*c*h+ a*r*h+r*c*h)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]

cnt=[0]*5

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
    else:pass

ans=0
keta=[0]*5
for i in range(7,29):
 
    for x in range(5):
        keta[x]=(i>>x)&1

    if sum(keta)!=3:
        continue
    
    product=1
    for j in range(5):
        if keta[j]==1:
            product*=cnt[j]

    ans+=product

print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
m=0
a=0
r=0
c=0
h=0

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

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

Solution (Python):
from itertools import combinations as comb
from collections import Counter


def main():
    n = int(input())
    ss = [input()[0] for _ in range(n)]
    marchs = ['M', 'A', 'R', 'C', 'H']
    ssc = Counter(ss)

    Counts = []
    for march in marchs:
        if march in ssc:
            Counts.append(ssc[march])

    ans = 0
    for a, b, c in comb(Counts, 3):
        ans += a*b*c
    print(ans)


if __name__ == "__main__":
    main()