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