100 #ABC089C. [ABC089C] March

[ABC089C] March

Score : 300300 points

Problem Statement

There are NN people. The name of the ii-th person is SiS_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 3232-bit integer type.

Constraints

  • 1N1051 \leq N \leq 10^5
  • SiS_i consists of uppercase English letters.
  • 1Si101 \leq |S_i| \leq 10
  • SiSj(ij)S_i \neq S_j (i \neq j)

Input

Input is given from Standard Input in the following format:

NN

S1S_1

::

SNS_N

Output

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

5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI
2

We can choose three people with the following names:

  • MASHIKE, RUMOI, HABORO
  • MASHIKE, RUMOI, HOROKANAI

Thus, we have two ways.

4
ZZ
ZZZ
Z
ZZZZZZZZZZ
0

Note that there may be no ways to choose three people so that the given conditions are met.

5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO
7