#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;

bool ng(string &s){
	return s.size()>1&&s[s.size()-1]=='X';
}
vi pl(string &t1,string &t2,int x){
	vi r(130);
	rep(i,129){
		int a=0,b=0;
		if(i<t1.size())a=t1[i]=='X'?x:t1[i]-'0';
		if(i<t2.size())b=t2[i]=='X'?x:t2[i]-'0';
		r[i]+=a+b;
		while(r[i]>9)r[i]-=10,r[i+1]++;
	}
	return r;
}
vi ev(string &s,int x){
	vi r(130);
	rep(i,130){
		int a=0;
		if(i<s.size())a=s[i]=='X'?x:s[i]-'0';
		r[i]=a;
	}
	return r;
}

int main(){
	string s,t1,t2,rhs;
	while(getline(cin,s)){
		reverse(s.begin(),s.end());
		int ans=-1, p=s.find("=");
		rhs=s.substr(0,p); s=s.substr(p+1); 
		p=s.find("+"); t2=s.substr(0,p); t1=s.substr(p+1);
		rep(x,10){
			if(x==0&&(ng(t1)||ng(t2)||ng(rhs)))continue;
			if(pl(t1,t2,x)==ev(rhs,x)){
				if(ans!=-1){
					cout<<"error"<<endl;
					return 1;
				}
				ans=x;
				//break;
			}
		}
		if(ans<0)cout<<"NA";
		else cout<<ans;
		cout<<endl;
	}
	return 0;
}