unittest
{
	assert( [ "5", "MASHIKE", "RUMOI", "OBIRA", "HABORO", "HOROKANAI" ].parse.expand.solve == 2 );
	assert( [ "4", "ZZ", "ZZZ", "Z", "ZZZZZZZZZZ" ].parse.expand.solve == 0 );
	assert( [ "5", "CHOKUDAI", "RNG", "MAKOTO", "AOKI", "RINGO" ].parse.expand.solve == 7 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto ss = new string[ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.strip;
	}
	return tuple( ss );
}

auto solve( string[] ss )
{
	// 各頭文字ごとにカウント
	auto cs = new long[ 5 ];
	foreach( i, u; "MARCH" )
	{
		cs[ i ] = ss.count!( ( a, b ) => a[0] == b )( u );
	}
	
	// 0件の頭文字は削除
	cs = cs.filter!( ( a ) => 0 < a ).array;
	if( cs.length < 3 ) return 0;
	
	// 組み合わせを計算
	auto t = 0L;
	for( auto a = 0; a < cs.length - 2; a++ )
	{
		for( auto b = a + 1; b < cs.length - 1; b++ )
		{
			for( auto c = b + 1; c < cs.length; c++ )
			{
				t += cs[ a ] * cs[ b ] * cs[ c ];
			}
		}
	}
	
	return t;
}
