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