def x(s)s.size>1&&s[0..0]=='X'end
while(l=gets)
l=~/([0-9X]+)\+([0-9X]+)=([0-9X]+)/
s=(x($1)||x($2)||x($3))?1:0
puts 'NA' if s.step(9){|i|if eval(($1+'+'+$2+'=='+$3).gsub('X',i.to_s)) then p i;break end}end