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)
    s2=s[2].gsub(/X/,x)
    s0==s0.to_i.to_s and s1==s1.to_i.to_s and s2==s2.to_i.to_s \
      and s0.to_i + s1.to_i == s2.to_i}
  puts (t.length==0) ? "NA" : t[0]
end