#include<iostream>
#include<string>

using namespace std;



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

	string inp;
	string tmp;
	string ans,le,ri;
	string wa;
	int j,zyo;
	int kot;
	int kapi;
	int kuri;

	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=0;
			ans=("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
			while(1){
				ans[zyo]=tmp[j];
				j--;
				zyo++;
				if(tmp[j]=='=') break;
			}
			j--;
			zyo=0;
			le=("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
			while(1){

				le[zyo]=tmp[j];
				j--;
				zyo++;
				if(tmp[j]=='+') break;
			}
			j--;
			zyo=0;
			ri=("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
			while(1){
				ri[zyo]=tmp[j];
				j--;
				zyo++;
				if(j==-1) break;
			}
			wa=("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
			kuri=0;
			for(int k=0;k<=200;k++){
				kapi=ri[k]-'0'+le[k]-'0'+kuri;
				wa[k]=(kapi%10)+'0';
				kuri=kapi/10;
			}
			if(wa==ans) kot=i;
		}
		if(kot!=-1) cout<<kot<<endl;
		else cout<<"NA"<<endl;
	}

	return 0;
}