def retnum(u, n)
  s = u.size
  a = 0
  i = 0
  u.each_char{|c|
    a += ((c == 'X')? n : c.to_i) * 10**(s-i-1)
    i += 1
  }
  return a
end

while true
  l = gets
  break if l.nil?
  u, z = l.chomp.split("=")
  x, y = u.split("+")
  ans = nil
  (0..9).each{|n|
    if retnum(x,n)+retnum(y,n) == retnum(z,n)
      ans = n
      break
    end
  }
  puts (ans.nil?)? "NA" : ans
end