module Main where
import Data.Char
int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = tail . words
printer = unlines . (:[]) . show

solver :: [String] -> Integer
solver ss = pattern ptn 3
  where
    ptn = map toInteger [
      length $ filter ((=='M') . head) ss,
      length $ filter ((=='A') . head) ss,
      length $ filter ((=='R') . head) ss,
      length $ filter ((=='C') . head) ss,
      length $ filter ((=='H') . head) ss
      ]

pattern :: [Integer] -> Int -> Integer
pattern [] 0 = 1
pattern [] _ = 0
pattern (m:ptn) select = 
  if m > 0 && select > 0 then
    m * pattern ptn (select-1)
      + pattern ptn select
  else
    pattern ptn select


