import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n getLine >>= print

solve :: [String] -> Int
solve = sum . map product . filter (\l -> length l == 3) . subsequences . map length . group . sort . filter (flip elem "MARCH") . map head
