object Main extends App {
  import scala.io.StdIn._

  val num = readLine.trim.split(' ').map(_.toInt)
  println((1 to 9).permutations.map(_.toArray).count{
    p ⇒ num.indices.forall(i ⇒ num(i) == -1 || num(i) == p(i)) && canMake(p)
  })

  def canMake(array: Array[Int]): Boolean = {
    array(0) + 10 * array(1) + array(2) + 100 * array(3) + 10 * array(4) + array(5) == 100 * array(6) + 10 * array(7) + array(8)
  }
}
