Олимпиадный тренинг

Задача 38588. March


Задача

Темы: Комбинаторика
There is a N person. The name of the ith person is Si . We want to select three people so that the following conditions are met:
- The name of each selected person starts with M, A, R, C or H< /code>; 
- there are no people whose names start with the same letter among the selected people.
How many ways are there to choose three people without paying attention to the order?

Input
The first line contains an integer (\(1<=N<=10^5\)) The next N lines contain names S - a string consisting only of English capital letters, the string length is not more than 10 characters. All names are different.

Imprint
Print the answer to the problem. Please note that the answer may not be a 32-bit integer type.
 

 

Examples
# Input Output Explanation
1 5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI
2 Three people can be selected in the following ways:

- MASHIKE, RUMOI, HABORO
MASHIKE, RUMOI, HOROKANAI

Answer: 2

2 4
ZZ
ZZZ
Z
ZZZZZZZZZZ
0  
3 5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO
7