{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B

main = do
    n <- readLn :: IO Int
    print.p'.filter (/=0).foldl' f [0,0,0,0,0] =<< replicateM n B.getLine
    where
        p' x
            | length x < 3 = 0
            | True = sum $ map product $ comb 3 x
        f aa@[m,a,r,c,h] (B.head -> s)
            | s == 'M' = [m+1,a,r,c,h]
            | s == 'A' = [m,a+1,r,c,h]
            | s == 'R' = [m,a,r+1,c,h]
            | s == 'C' = [m,a,r,c+1,h]
            | s == 'H' = [m,a,r,c,h+1]
            | True = aa

comb :: Int -> [Int] -> [[Int]]
comb n xa@(x:xs) =
    case compare (length xa) n of
        LT -> []
        EQ -> [xa]
        GT -> ( map (x:) $ comb (n-1) xs) ++ (comb n xs)
comb 0 _ = [[]]
comb _ [] = []