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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

//#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int n;
int cnt=0;
char g[20];
string s[10010];
long long int ans=0;

int v1[9]={0,0,0,0,0,1,1,1,2};
int v2[9]={1,1,1,2,2,2,2,3,3};
int v3[9]={2,3,4,3,4,3,4,4,4};

int powa(int d,int e){
    if(e<0)return 0;
    return pow(d,e);
}

int ini[5];

int main(){
    cin>>n;
    REP(i,n){
        cin>>g;
        //g=g.substr(0,1);
        //cout<<g[0];
        if(g[0]=='M'){
            ini[0]++;
        }if(g[0]=='A'){
            ini[1]++;
        }if(g[0]=='R'){
            ini[2]++;
        }if(g[0]=='C'){
            ini[3]++;
        }if(g[0]=='H'){
            ini[4]++;
        }

    }

    int c=0;
    REP(i,5){
        if(ini[i]>0)c++;
    }
    if(c<3){
        cout<<0<<endl;
        return 0;
    }


    REP(i,9){
        ans+=ini[v1[i]]*ini[v2[i]]*ini[v3[i]];
    }


    cout<<ans<<endl;
    
    

    return 0;
}