import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine().toInt
  val linse = (0 until n).map(_ => StdIn.readLine())
  
  val d = Array.fill[Long](5)(0)
  
  linse.foreach{ l =>
    val idx = l.charAt(0) match {
      case 'M' => 0
      case 'A' => 1
      case 'R' => 2
      case 'C' => 3
      case 'H' => 4
      case _ => -1
    }
    if(0 <= idx) d(idx) += 1
  }
  val co = List(0, 1, 2, 3, 4).combinations(3)
  println(co.mkString(" "))
  var r = 0L
  co.foreach{ p =>
    r += d(p(0))*d(p(1))*d(p(2))
  }
  println(r)
  
}