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


#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion

//// ABC 172 C-Tsundoku
//static int a[200001];
//
//int main(void) {
//	int  n, m,k,i;
//	ll  kk=0,sum=0;
//	int b;
//
//	scanf("%d %d %d", &n,&m,&k);
//
//	for (i = 0; i < n; i++) {
//		scanf("%d", &a[i]); 
//		if (k < kk + a[i]) break;
//		kk += a[i];
//		sum ++;
//	}        //aのみ読んだ時の最大数
//
//	printf("a sum:%lld kk:%lld\n", sum,kk);
//
//
//	if (!sum) {					    //aは一冊も読めない場合
//		for (int j = 0; j < m; j++) {  //ｂのみ読む
//			scanf("%d", &b);
//			if (k < kk+b) continue;
//			kk += b;
//			sum++;
//		}
//		printf("%lld\n", sum);
//		return 0;
//	}
//
//	i = sum - 1;
//	for (int j = 0; j < m; j++) {  
//			scanf("%d", &b);
//			kk=kk-a[i]+b;          //aの最後とbを入れ替え
//			if (k <= kk) {
//				if (i == 0) break; //入れ替えるaがない
//				i--;
//			}
//			else {
//				sum = _max((ll)i + (ll)j, sum);
//			} 
//		}
//	
//   printf("%lld\n", sum);
//	
//   return 0;
//}

//ABC 089 C-March
static int a[5];
int main(void) {
	ll cnt;
	int n, i;
	char s[11];
	int fa[5] = { 0,0,0,0,0 };

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", s);
		switch (s[0]) {
		case 'M':a[0]++; fa[0] = 1; break;
		case 'A':a[1]++; fa[1] = 1; break;
		case 'R':a[2]++; fa[2] = 1; break;
		case 'C':a[3]++; fa[3] = 1; break;
		case 'H':a[4]++; fa[4] = 1; break;
		default:break;
		}
	}
	
	int f = fa[0] + fa[1] + fa[2] + fa[3] + fa[4];
	if (f < 3) {
		printf("0\n"); return 0;
	}

	ll ans = 0;
	ans = f * (f - 1) * (f - 2) / (1 * 2 * 3);
	for (i = 0; i < 5; i++) {
		if (a[i] <= 1) continue;
		ans = ans + ((ll)a[i] - 1) * ((f-1)*(f-2) / (1 * 2));
	}

	printf("%lld", ans);
	return 0;
}