import Data.List

f :: String->Bool
f x=(head x) `elem` "MARCH"

f2 :: [Integer]->[Integer]->Integer
f2 (a:b:c:[]) _ =a*b*c
f2 _ []=0
f2 xs (y:ys)=(f2 (y:xs) ys) + (f2 xs ys)

main =do
      x<-getLine
      y<-getContents
      let ys=map head $ filter f $ lines y
          zs=map fromIntegral $ map length $ group $ sort ys
      print $ f2 [] zs