import Data.List

gather [] = []
gather list@(x:xs) = length b : gather a
  where
    (b,a) = span (==x) list


main = do
  n <- getLine
  s <- getContents >>= return . gather . sort . map head . (filter (\(x:_) -> elem x "MARCH")) . lines

  print $ f s

  where
    f [] = 0
    f (x:xs) = x * (g xs) + f xs
    g [] = 0
    g (x:xs) = x * (sum xs) + g xs
