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

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

reg = Regexp.new("[+=]")
while fh.gets do
  s=$_.chomp.split(reg)
  a,b = s2coeff(s[0])
  c,d = s2coeff(s[1])
  e,f = s2coeff(s[2])

  if (a+c-e)!=0 and (f-b-d)%(a+c-e)==0 then
    ans =  (f-b-d)/(a+c-e)
  else
    ans="NA"
  end
  puts ans
end