while io = gets
  break if io.strip == ""
  t = /([0-9X]+)\+([0-9X]+)=([0-9X]+)/.match(io)
  first, second, right = t[1], t[2], t[3]

  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
    x, y, z = [first, second, right].map {|s| s.gsub(/X/, i.to_s).to_i}
    if x + y == z
      answer =  i.to_s
      break
    end
  end

  puts answer ? answer : "NA"
end