#include<iostream>
#include<string>

using namespace std;



int main(void){
	std::ios_base::sync_with_stdio();

	string inp;
	string tmp;
	long long ans,le,ri;
	long long j,zyo;
	long long kot;

	while(cin>>inp){
		kot=-1;
		for(int i=0;i<=9;i++){
			tmp=inp;
			for(int k=0;k<tmp.length();k++){
				if(tmp[k]=='X') tmp[k]=i+'0';
			}
			j=tmp.length()-1;
			zyo=1;
			ans=0;
			while(1){
				ans+=(tmp[j]-'0')*zyo;
				j--;
				zyo*=10;
				if(tmp[j]=='=') break;
			}
			j--;
			zyo=1;
			le=0;
			while(1){
				le+=(tmp[j]-'0')*zyo;
				j--;
				zyo*=10;
				if(tmp[j]=='+') break;
			}
			j--;
			zyo=1;
			ri=0;
			while(1){
				ri+=(tmp[j]-'0')*zyo;
				j--;
				zyo*=10;
				if(j==-1) break;
			}
			if(le+ri==ans) kot=i;
		}
		if(kot!=-1) cout<<kot<<endl;
		else cout<<"NA"<<endl;
	}

	return 0;
}