
while io = gets
  break if io.strip == ""
  left,right   = io.split("=")
  first,second = left.split("+")
  start = (first != "X" && first[0] == "X") || (second != "X" && second[0] == "X") || (right != "X" && right[0] == "X") ? 1 : 0

  answer = nil

  start.upto(9) do |i|
    x  = first.gsub(/X/,i.to_s).to_i
    y = second.gsub(/X/,i.to_s).to_i
    z  = right.gsub(/X/,i.to_s).to_i
    if x + y == z
      answer =  i.to_s
      break
    end
  end

  puts answer ? answer : "NA"

end