def erase_first_zero_then_eval(lo, ro, ans)
	return false if lo[0] == "0" or ro[0] == "0"
	return lo.to_i + ro.to_i == ans.to_i
end
readlines.each do |l|
	(0..9).to_a.each do |x|
		lo, ro, ans = l.gsub("X", x.to_s).scan(/\d+/)
		p [lo, ro, ans]
		if erase_first_zero_then_eval(lo, ro, ans)
			puts x
			break
		end
		puts "NA" if x == 9
	end
end