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

  flag = false

  start.upto(9) do |i|
    first_sub  = first.gsub("X",i.to_s).to_i
    second_sub = second.gsub("X",i.to_s).to_i
    right_sub  = right.gsub("X",i.to_s).to_i
    if first_sub + second_sub == right_sub
      puts i
      flag = true
      break
    end
  end

  puts "NA" unless flag

end