import Data.Bits
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=print.solve.B.lines=<<B.getContents
solve=f.V.accum(+)(V.replicate 5 0).map(\i->(i,1)).mapMaybe((`elemIndex`"MARCH").B.head)
f c=sum.map g$filter(\b->popCount b==3)[7..2^5]where
  g::Int->Int
  g b=product.map(c V.!)$filter(testBit b)[0..4]