while gets do
  s=$_.chomp.split(/[+=]/)
  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)
    reg=Regexp.new("^(0|[1-9][0-9]*)$")
    s0=~reg and s1=~reg and s2=~reg and s0.to_i + s1.to_i == s2.to_i}
  puts (t.length==0) ? "NA" : t[0]
end