import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  val target = "01+-*()="
  val exp = readLine.trim.toList
  val symbol = if (exp.contains('=')) target.filterNot(_ == '=') else target
  val suspects = exp.filter(_.isLetter).distinct
  var result = 0
  for (usage ← symbol.combinations(suspects.length)){
    for (map ← usage.permutations.map{u ⇒ suspects.zip(u).toMap.withDefault(c ⇒ c)}){
      exp.map(map) match {
        case Q() ⇒ result += 1
        case _ ⇒
      }
    }
  }
  println(result)

  object Q{
    def unapply(arg: List[Char]): Boolean = {
      arg match {
        case l E '='::(r E Nil) ⇒ l == r
        case _ ⇒ false
      }
    }
  }
  object E{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case l T t ⇒ Some(takeAll(t, l))
        case _ ⇒ None
      }
    }
    @tailrec
    private[this] def takeAll(arg: List[Char], left: Int): (Int, List[Char]) = {
      arg match {
        case '-'::(r T t) ⇒ takeAll(t, left - r)
        case '+'::(r T t) ⇒ takeAll(t, left + r)
        case _ ⇒ (left, arg)
      }
    }
  }
  object T{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case l F t ⇒ Some(takeAll(t, l))
        case _ ⇒ None
      }
    }
    @tailrec
    private[this] def takeAll(arg: List[Char], left: Int): (Int, List[Char]) = {
      arg match {
        case '*'::(r F t) ⇒ takeAll(t, left * r)
        case _ ⇒ (left, arg)
      }
    }
  }
  object F{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case n N t ⇒ Some(n, t)
        case '-'::(f F t) ⇒ Some(-f, t)
        case '('::(e E ')'::t) ⇒ Some(e, t)
        case _ ⇒ None
      }
    }
  }
  object N{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg.span(_.isDigit) match {
        case ('0'::Nil, t) ⇒ Some(0, t)
        case (n@'1'::_, t) ⇒ Some(n.foldLeft(0){(a, b) ⇒ a * 2 + b.asDigit}, t)
        case _ ⇒ None
      }
    }
  }
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}
