while line = gets
  l, r = line.chomp.split('=')
  
  answer = nil
  for i in 0..9
    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) ? answer : :NA
end