#!/usr/bin/ruby
while(l=gets)do
	if l.length<2 then raise l end
	l=~/([0-9X]+)\+([0-9X]+)=([0-9X]+)/
	s=($1[0..0]=='X'||$2[0..0]=='X'||$3[0..0]=='X')?1:0
	a=$1+'+'+$2+'=='+$3
	if s==0 then raise a end
	puts 'NA' if s.step(9){|i|if eval(a.gsub('X',i.to_s)) then p i;break end}
end