P7566 Sated

Description

There are $n$ rabbits in the bookworm’s backpack. The $i$-th rabbit is labeled by the bookworm with a string $S_i$ consisting of uppercase letters. The bookworm knows +C+, and he used +C+ to write a `random` function that randomly picked three rabbits. However, the bookworm has temporarily developed anorexia nervosa. He can eat these three rabbits if and only if: - The first letter of each label is one of `M`, `C`, `O`, or `I`. - The first letters of the labels must be all different. The bookworm wants to know how many ways there are to choose three rabbits so that he can eat the chosen rabbits.

Input Format

The first line contains an integer $n$, representing the number of rabbits. The next $n$ lines each contain a string $S_i$, representing one rabbit.

Output Format

Output one integer on a single line, representing the answer.

Explanation/Hint

#### Explanation for Sample 1 There are $7$ ways to choose: - `MINE`, `CRAFT`, `OLYMPIAD`. - `MINE`, `CRAFT`, `IN`. - `MINE`, `CRAFT`, `INFORMATICS`. - `MINE`, `OLYMPIAD`, `IN`. - `MINE`, `OLYMPIAD`, `INFORMATICS`. - `CRAFT`, `OLYMPIAD`, `IN`. - `CRAFT`, `OLYMPIAD`, `INFORMATICS`. #### Constraints **This problem uses bundled tests.** - Subtask 1 (10 pts): The first letter of every $S_i$ is `M`. - Subtask 2 (30 pts): $n \le 100$. - Subtask 3 (60 pts): No special constraints. For $100\%$ of the testdata, $1 \le n \le 10^5$, $1 \le |S_i| \le 11$, and $S_i$ consists of uppercase letters. The testdata does not guarantee that all $S_i$ are distinct. Translated by ChatGPT 5