while line = gets
  stack = line.chomp.split(/(\+|=)/)
  l = sprintf('%s%s%s', stack[0], stack[1], stack[2])
  r = sprintf('%s', stack[4])

  if stack[0] !~ /^X/ && stack[2] !~ /^X/ && stack[4] !~ /^X/
    range = 0..9
  else
    range = 1..9
  end

  answer = :NA
  for i in range
    if eval(l.gsub('X', i.to_s)).to_i == r.gsub('X', i.to_s).to_i
      answer = i
      break
    end
  end

  puts answer
end