import scala.io.StdIn.{readInt,readLine}

object Main {

  def main(args:Array[String]) = {
    Iterator.continually(readLine).takeWhile(_!=null).foreach { s =>
      val n = s.split("\\+")
      val m = n(1).split("=")
      val a = n(0);val b = m(0);val c = m(1)
      val range = if(a(0)=='X' || b(0)=='X' || c(0)=='X') '1' to '9' else '0' to '9'
      val result = range.find{ e =>
        BigInt(a.replace('X',e))+BigInt(b.replace('X',e)) == BigInt(c.replace('X',e))
      }.map(_.toString).getOrElse("NA")
      println(result)
    }
  }
}