#include<string>
#include<vector>
#include<algorithm>
#define repg(i,n) for(i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
int x,p,i; string s,t1,t2,rhs;
bool cmp(vi a,vi b,vi c){
	bool f=1;
	vi r(c.size());
	if(max(a.size(),b.size())>c.size())return 0;
	repg(i,c.size()){
		int A=i<a.size()?a[i]:0,B=i<b.size()?b[i]:0;
		r[i]+=(A+B)%10;
		if(i+1<c.size())r[i+1]=(A+B)/10;
		else if((A+B)/10>0)return 0;
	}
	return r==c;
}
vi ev(string &s){
	vi r(s.size());
	repg(i,s.size())r[i]=s[i]=='X'?x:s[i]-'0';
	return r;
}
bool xck(string &s){
	return s.size()>1&&s[s.size()-1]=='X';
}
int main(){
	while(cin>>s){
		reverse(s.begin(),s.end());
		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);
		repg(x,10)if(cmp(ev(t1),ev(t2),ev(rhs))){
			if(x==0&&(xck(t1)||xck(t2)||xck(rhs)))continue;
			cout<<x<<endl; goto NEXT;
		}
		cout<<"NA"<<endl; NEXT:;
	}
	return 0;
}