#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		vector<int> v;
		int ans=-1;int f=0;
		for(int i=s.size()-1,frag=0;i>-1;--i){
			if(s[i]=='X'||('0'<=s[i]&&s[i]<='9')){
				++frag;
				if(s[i]=='X'){
					v.push_back(i);
					if(i==0&&frag>=2)f=1;
				}dd
			}
			else if(s[i]=='+'||s[i]=='='){
				if(frag>=2)f=1;
				frag=0;
			}else frag=0;
		}
		for(int i=f,a,b,c;i<10;++i){
			for(int j=0;j<v.size();++j){
				s[v[j]]=i+'0';
			}
			sscanf(s.c_str(),"%d+%d=%d",&a,&b,&c);
			if(a+b==c)ans=i;
		}
		if(ans!=-1) cout<<ans<<"\n";
		else cout<<"NA\n";
	}
	return 0;
}