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

main = do
  _ <- getLine
  ss <- B.lines <$> B.getContents
  let ns = (map length . groupBy (\s1 s2 -> B.head s1 == B.head s2) . sort . filter ((flip elem "MARCH") . B.head)) ss
  let ans = sum $ do
        let ins = zip [0..] ns
        (i,x) <- ins
        (j,y) <- delete (i,x) ins
        (k,z) <- delete (j,y) (delete (i,x) ins)
        guard (i<j && j<k)
        pure (x*y*z)
  print ans