import sys
import re
for line in sys.stdin:
	line=re.split('[+=]',line)
	flag=True
	for i in range(10):
		if(line[0][0]=='X'or line[1][0]=='X'or line[2][0]=='X')and i==0:continue
		cnt=0
		for j in range(2):
			s=line[j]
			s=s.replace('X',str(i))
			cnt+=int(s)
		s=line[2]
		s=s.replace('X',str(i))
		if cnt==int(s):
			flag=False
			print(i)
			break
	if flag:print("NA")