[<EntryPoint>]
let main argv =
    let N = stdin.ReadLine() |> int
    let counter =
        [| for _ in 1..N -> 
            stdin.ReadLine().[0]
        |]
        |> Array.countBy id
        |> Array.filter (fun (c, _) -> "MARCH".Contains(c.ToString()))
        |> Array.map (fun (c, x) -> c, (int64 x))
    let n = counter |> Array.length
    if n < 3 then 0L
    else
        let counts a b c =
            List.fold (fun total i -> total * (snd counter.[i])) 1L [a; b; c]
        let rec dfs a b c count =
            if a >= n-2 then count
            elif b = n-2 then dfs (a+1) (a+2) (a+3) (count + (counts a b c))
            elif c = n-1 then dfs a (b+1) (b+2) (count + (counts a b c))
            else dfs a b (c+1) (count + (counts a b c))
        dfs 0 1 2 0L
    |> stdout.WriteLine
    0 // return an integer exit code
