fun c89(args: Array<String>) {
    val people = args.drop(1)
    val peopleList = listOf(
            people.count { it.startsWith("M") },
            people.count { it.startsWith("A") },
            people.count { it.startsWith("R") },
            people.count { it.startsWith("C") },
            people.count { it.startsWith("H") })

    fun dfs(list: List<Int>, remain: Int): Long {
        if (remain == 0) {
            return 1L
        }
        val indexValueList = list
                .mapIndexed { index, i -> Pair(index, i) }
                .filter { it.second > 0 }
        if (indexValueList.isEmpty()) {
            return 0L
        }
        return indexValueList
                .map {
                    val (index, value) = it
                    val nextList = list.drop(index + 1)
                    value.toLong() * dfs(nextList, remain - 1)
                }
                .sum()
    }

    val ans = dfs(peopleList, 3)
    println(ans)
}

fun main(args: Array<String>) {
    c89(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}