#include <iostream>
#include <sstream>
#include <string>
#include <cctype>
using namespace std;

bool check(string S){
	size_t cur=0;
	int a=0,b=0,c=0;
	a+=S[cur++]-'0';
	while(isdigit(S[cur]))
		a=a*10+S[cur++]-'0';
	cur++;
	b+=S[cur++]-'0';
	while(isdigit(S[cur]))
		b=b*10+S[cur++]-'0';
	cur++;
	c+=S[cur++]-'0';
	while(isdigit(S[cur]))
		c=c*10+S[cur++]-'0';
//	cout << S << endl;
//	cout << a <<' ' << b<< ' ' << c << endl;
	if(a+b==c)
		return true;
	else
		return false;
}

int main(void){
	while(true){
		bool ok=false;
		string S,T;
		cin >> S;
		if(cin.eof())
			break;
		for(int i=0;i<10;i++){
			T=S;
			ostringstream stream;
			stream << i;
			string tmp=stream.str();
			while(T.find('X')!=-1)
				T.replace(T.find('X'),1,tmp);
			if(check(T))
				cout << i << endl,ok=true,i=10;
		}
		if(!ok)
		cout << "NA" << endl;
	}
	return 0;
}