while s = gets
  break if s.strip == ""
  _ = s.match /([0-9X]+)\+([0-9X]+)\=([0-9X]+)/
  a = _[1]
  b = _[2]
  c = _[3]
  answer = nil
  (0..9).each do|i|
    next if i == 0 && (a != 'X' && a[0] == 'X' ||
                       b != 'X' && b[0] == 'X' ||
                       c != 'X' && c[0] == 'X')
    x = a.gsub(/X/, i.to_s).to_i
    y = b.gsub(/X/, i.to_s).to_i
    z = c.gsub(/X/, i.to_s).to_i
    if x + y == z
      answer = i
      break
    end
  end
  puts answer ? answer.to_s : 'NA'
end