# ABC089 C - March

N = int(eval(input()))

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



x = [0,0,0,0,0,0,1,1,1,2]

y = [1,1,1,2,2,3,2,2,3,3]

z = [2,3,4,3,4,4,3,4,4,4]



m = 0

a = 0

r = 0

c = 0

h = 0



for s in S:

    if s[0:1] == 'M':

        m += 1

    if s[0:1] == 'A':

        a += 1

    if s[0:1] == 'R':

        r += 1

    if s[0:1] == 'C':

        c += 1

    if s[0:1] == 'H':

        h += 1



ans = 0

D = []

D.append(m)

D.append(a)

D.append(r)

D.append(c)

D.append(h)



for d in range(10):

    ans += D[x[d]]*D[y[d]]*D[z[d]]

print(ans)



n=int(eval(input()))

m=0

a=0

r=0

c=0

h=0

for i in range(n):

    s=eval(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=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)
# ABC089 C - March
N = int(eval(input()))
S = [eval(input()) for i in range(N)]
x = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2]
y = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3]
z = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4]
m = 0
a = 0
r = 0
c = 0
h = 0
for s in S:
    if s[0:1] == "M":
        m += 1
    if s[0:1] == "A":
        a += 1
    if s[0:1] == "R":
        r += 1
    if s[0:1] == "C":
        c += 1
    if s[0:1] == "H":
        h += 1
ans = 0
D = []
D.append(m)
D.append(a)
D.append(r)
D.append(c)
D.append(h)
for d in range(10):
    ans += D[x[d]] * D[y[d]] * D[z[d]]
print(ans)

n = int(eval(input()))
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
    s = eval(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 = 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)

-# ABC089 C - March -N = int(eval(input())) -S = [eval(input()) for i in range(N)] -x = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2] -y = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3] -z = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4] +n = int(eval(input())) -for s in S: -    if s[0:1] == "M": +for i in range(n): +    s = eval(input()) +    if s[0] == "M": -    if s[0:1] == "A": +    elif s[0] == "A": -    if s[0:1] == "R": +    elif s[0] == "R": -    if s[0:1] == "C": +    elif s[0] == "C": -    if s[0:1] == "H": +    elif s[0] == "H": -D = [] -D.append(m) -D.append(a) -D.append(r) -D.append(c) -D.append(h) -for d in range(10): -    ans += D[x[d]] * D[y[d]] * D[z[d]] +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