object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)

    while (sc.hasNext()) {
      val s = sc.next() split Array('+', '=')
      val ans = (0 to 9).find(X => {
        val a = s(0).replaceAll("X", "" + X)
        val b = s(1).replaceAll("X", "" + X)
        val c = s(2).replaceAll("X", "" + X)
        val flg = (check(a) && check(b) && check(c) && BigInt(a) + BigInt(b) == BigInt(c))
        flg
      })

      println(ans.getOrElse("NA"))
    }
  }

  private def check(s: String): Boolean = {
    val res: Boolean = (s.length == 1 || s(0) != '0')
    res
  }
}