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).to_i
    end
    p h
    if h[0]+h[1]==h[2]
      puts i
      flag=false
      break
    end
  end
  if flag
    puts "NA"
  end
end