import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readStrLines :: IO [BC.ByteString]
readStrLines = BC.lines <$> BC.getContents

countUp :: [BC.ByteString] -> [Int] ->  [Int]
countUp [] march = march
countUp (s:ss) [m, a, r, c, h]
  | BC.head s == 'M' = countUp ss [m + 1, a, r, c, h]
  | BC.head s == 'A' = countUp ss [m, a + 1, r, c, h]
  | BC.head s == 'R' = countUp ss [m, a, r + 1, c, h]
  | BC.head s == 'C' = countUp ss [m, a, r, c + 1, h]
  | BC.head s == 'H' = countUp ss [m, a, r, c, h + 1]
  | otherwise = countUp ss [m, a, r, c, h]

comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

main :: IO ()
main = do
  getLine
  ss <- readStrLines
  print . sum . map product . comb 3 $ countUp ss [0, 0, 0, 0, 0]
