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

while fh.gets do
  s=$_.chomp.split(/=/)
  ans=("0".."9").to_a.select{|x|
       s0=s[0].gsub(/X/,x); s1=s[1].gsub(/X/,x)
    s0 !~/^0/ and s1 !~/^0/ and eval(s0)==eval(s1)}

  puts (ans.length==0) ? "NA" : ans

end