import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!long;
    auto cnt = sort(N.iota.map!(_ => readln.front).array.filter!(c => "MARCH".canFind(c)).array).group.map!(g => cast(long)g[1]).array;
    auto res = 0;
    cnt.length.iota.map!(i =>
        iota(i+1, cnt.length).map!(j => 
            iota(j+1, cnt.length).map!(k => 
                cnt[i] * cnt[j] * cnt[k]
            ).sum
        ).sum
    ).sum.writeln;
}

