fh=STDIN
while fh.gets do
  reg = Regexp.new("=")
  s=$_.chomp.split(reg)
  t =("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 (t.length==0) ? "NA" : t
end