Problem:
Score : 300 points

Problem Statement

There are N people. The name of the i-th person is S_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 32-bit integer type.

Constraints

1 \leq N \leq 10^5

S_i consists of uppercase English letters.

1 \leq |S_i| \leq 10

S_i \neq S_j (i \neq j)

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

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

Sample Input 1

5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI

Sample Output 1

2

We can choose three people with the following names:

MASHIKE, RUMOI, HABORO

MASHIKE, RUMOI, HOROKANAI

Thus, we have two ways.

Sample Input 2

4
ZZ
ZZZ
Z
ZZZZZZZZZZ

Sample Output 2

0

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

Sample Input 3

5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO

Sample Output 3

7

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

package AC;
/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		List<String> M = new ArrayList<String>();
		List<String> A = new ArrayList<String>();
		List<String> R = new ArrayList<String>();
		List<String> C = new ArrayList<String>();
		List<String> H = new ArrayList<String>();

		String now;
		for (int i = 0; i < N; i++) {
			now = br.readLine();
			switch (now.charAt(0)) {
			case 'M':
				//if (!M.contains(now))
					M.add(now);
				break;
			case 'A':
				//if (!A.contains(now))
					A.add(now);
				break;
			case 'R':
				//if (!R.contains(now))
					R.add(now);
				break;
			case 'C':
				//if (!C.contains(now))
					C.add(now);
				break;
			case 'H':
				//if (!H.contains(now))
					H.add(now);
				break;
			}
		}

		List<Integer> march = new ArrayList<Integer>(Arrays.asList(M.size(), A.size(), R.size(), C.size(), H.size()));

		for (int i = 4; i >= 0; i--) {
			if (march.get(i) == 0)
				march.remove(i);
		}

		long count = 0;

		for (int a = 0; a < march.size(); a++) {
			for (int b = a; b < march.size(); b++) {
				for (int c = b; c < march.size(); c++) {
					if (a == b || b == c || c == a) {
					} else {
						count += march.get(a) * march.get(b) * march.get(c);
					}
				}
			}
		}

		System.out.println(count);

	}
}