#P7566. 饱食

饱食

Problem Description

There are nn rabbits in the bookworm’s backpack. The ii-th rabbit is labeled by the bookworm with a string SiS_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 nn, representing the number of rabbits.

The next nn lines each contain a string SiS_i, representing one rabbit.

Output Format

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

5
MINE
CRAFT
OLYMPIAD
IN
INFORMATICS
7

Hint

Explanation for Sample 1

There are 77 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 SiS_i is M.
  • Subtask 2 (30 pts): n100n \le 100.
  • Subtask 3 (60 pts): No special constraints.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 1Si111 \le |S_i| \le 11, and SiS_i consists of uppercase letters.

The testdata does not guarantee that all SiS_i are distinct.

Translated by ChatGPT 5