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 C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections;
using System.Text;
class Program {
    static void Main(string[] args) {
#if LOCAL_ENVIRONMENT
        var stdin = new System.IO.StreamReader("stdin.txt");
        System.Console.SetIn(stdin);
#endif
        Inputer cin = new Inputer();
        var N = cin.GetInt();
        var S = cin.GetStringArray(N);
        long[] cnt = new long[26];
        char[,] t = new char[,] {
            {'M', 	'A', 	'R'}, 
            {'M', 	'A', 	'C'}, 
            {'M', 	'A', 	'H'}, 
            {'M', 	'R', 	'C'}, 
            {'M', 	'R', 	'H'}, 
            {'M', 	'C', 	'H'}, 
            {'A', 	'R', 	'C'}, 
            {'A', 	'R', 	'H'}, 
            {'A', 	'C', 	'H'}, 
            {'R', 	'C', 	'H'}, 
        };
        for (var n = 0; n < N; n++) {
            cnt[S[n][0] - 'A']++;
        }
        long ans = 0;
        for (var n = 0; n < 10; n++) {
            long c0 = cnt[t[n, 0] - 'A'];
            long c1 = cnt[t[n, 1] - 'A'];
            long c2 = cnt[t[n, 2] - 'A'];
            ans += c0 * c1 * c2;
        }
        Console.Error.WriteLine($"{ans}");

    } //main
    public class Inputer {
        private int cnt;
        private string[] items;
        public Inputer() {
            this.cnt = 0;
            var sb = new StringBuilder();
            var s = Console.ReadLine();
            while (s != null) {
                sb.Append(s + " ");
                s = Console.ReadLine();
            }
            this.items = sb.ToString().Split(' ');
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("items: {0}", this.items.ToStringA());
#endif
        }
        public void SetCnt(int n) { this.cnt = n; }
        public int GetInt() {
            return int.Parse(this.items[this.cnt++]);
        }
        public long GetLong() {
            return long.Parse(this.items[this.cnt++]);
        }
        public string GetString() {
            return this.items[this.cnt++];
        }
        public int[] GetIntArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var r = new int[n];
            for (var i = 0; i < n; i++) r[i] = this.GetInt();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("[{0}]", string.Join(", ", r));
#endif
            return r;
        }
        public long[] GetLongArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var r = new long[n];
            for (var i = 0; i < n; i++) r[i] = this.GetLong();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("[{0}]", string.Join(", ", r));
#endif
            return r;
        }
        public string[] GetStringArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var r = new string[n];
            for (var i = 0; i < n; i++) r[i] = this.GetString();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("[{0}]", string.Join(", ", r));
#endif
            return r;
        }
        public int[][] GetInt2Col(int n) {
            const int M = 2;
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            int[][] r = new int[M][] {
                new int[n],
                new int[n],
            };
            for (var i = 0; i < n; i++) {
                r[0][i] = this.GetInt();
                r[1][i] = this.GetInt();
            }
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("[");
            for (var i = 0; i < M; i++)
                Console.Error.WriteLine("  [{0}],", string.Join(", ", r[i]));
            Console.Error.WriteLine("]");
#endif
            return r;
        }

    }

} //class

static class Extensions {
    public static string ToStringA<T>(this T[] array, string separator = ", ", string braces = "[]") {
        string bL = braces.Length > 0 ? braces[0].ToString() : "";
        string bR = braces.Length > 1 ? braces[1].ToString() : "";
        return bL + String.Join(separator, array) + bR;
    }
}