#P7566. Bookworm's Rabbit Feast

    ID: 20760 Type: Default 1000ms 256MiB

Bookworm's Rabbit Feast

Bookworm's Rabbit Feast

Problem Statement:

Bookworm has \(n\) rabbits in his bag, where the \(i\)-th rabbit is labeled with an uppercase letter string \(S_i\). Bookworm uses a random function he wrote to randomly select three rabbits.

However, due to his peculiar condition, he can only eat the selected three rabbits if both of the following conditions are met:

  • The first letter of each rabbit's label is one of \(\{M, C, O, I\}\).
  • The three selected rabbits must have distinct first letters.

Determine the number of ways to choose three rabbits that Bookworm can eat.

inputFormat

Input Format:

  1. The first line contains an integer \(n\) indicating the number of rabbits.
  2. Each of the next \(n\) lines contains a string \(S_i\) which is the label of the \(i\)-th rabbit.

outputFormat

Output Format:

Output a single integer representing the number of valid ways to select three rabbits that satisfy the given conditions.

sample

3
MOUSE
COOKIE
ORBIT
1