import Data.List

combinations :: Int -> [a] -> [[a]]
combinations 0 _  = [[]]
combinations n xs = [ y:ys | y:xs' <- tails xs
                           , ys <- combinations (n-1) xs' ]

main :: IO ()
main = do
    _ <- getLine
    s <- lines <$> getContents :: IO [String]
    let s' = combinations 3 [ head i | i <- s, head i `elem` "MARCH" ]
    print . length $ [ is | is <- s', 3 == (length . group $ is)]
