def s2coeff(s)
  t = s.split(//)
  a = 0
  b = 0
  while t.length > 0
    a = a*10
    b = b*10
    x=t.shift
    if x=="X" then
      a += 1
    else
      b += x.to_i
    end
  end
   [a,b]
end

def goodNumberStr(x)
  x =~ /^0|[1-9X][0-9X]*$/
end

def goodNumber(x)
  x =~ /^[1-9][0-9]*$/
end

if true then
  fh=STDIN
else
  fh=open("in0110.txt")
end

reg = Regexp.new("[+=]")
while fh.gets do
  s=[]
  $_.chomp =~ /([0-9X]+)\+([0-9X]+)=([0-9X]+)/
  s[0]=$1
  s[1]=$2
  s[2]=$3
  if not goodNumberStr(s[0]) then
    puts "NA"
    next
  end
  if not goodNumberStr(s[1]) then
    puts "NA"
    next
  end
  if not goodNumberStr(s[2]) then
    puts "NA"
    next
  end

  a,b = s2coeff(s[0])
  c,d = s2coeff(s[1])
  e,f = s2coeff(s[2])

  if (a+c-e)==0 then
    puts "NA"
    next
  end
  y = (f-b-d)/(a+c-e)
  s0=s[0].gsub(/X/, y.to_s)
  s1=s[1].gsub(/X/, y.to_s)
  s2=s[2].gsub(/X/, y.to_s)
  if (f-b-d)%(a+c-e)==0 and goodNumberStr(s[0].gsub(/X/,y.to_s)) and goodNumberStr(s[1].gsub(/X/,y.to_s)) and goodNumberStr(s[2].gsub(/X/,y.to_s)) and s0.to_i.to_s==s0 and s1.to_i.to_s==s1 and s2.to_i.to_s==s2 then
    puts y
  else
    puts "NA"
  end
end