def add(a,b)
  a.reverse!
  b.reverse!
  n = [a.length,b.length].min
  m = [a.length,b.length].max
  r = Array.new(m,0)
  for i in 0.. n-1
    t = a[i].to_i+b[i].to_i
    if t > 9
      r[i] += t-10
      r[i+1] += 1
    else
      r[i] += t
    end
  end
  c = a
  if a[n] == NIL then c = b end
  for i in n.. m-1
    r[i] = c[i]
  end
  return r.reverse.join
end

while g=gets
  g=g.chomp.split(/[+=]/)
  p g
  h=[]
  l=0
  flag=true
  if g[0][0]=="X" || g[1][0]=="X" || g[2][0]=="X" then l=1 end
  for i in l.. 9
    for j in 0.. 2
      h[j]=g[j].gsub("X",i.to_s)
    end
    if add(h[0],h[1])==h[2]
      puts i
      flag=false
      break
    end
  end
  if flag
    puts "NA"
  end
end