#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int stoi(string s){
	int res=0;
	for(int i=s.size()-1;i>=0;i--)res+=(int)(s[i]-'0')*pow(10,s.size()-1-i);
	return res;
}

int lackstoi(string s,int x){
	int res=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='X')res+=x*pow(10,s.size()-1-i);
		else res+=(int)(s[i]-'0')*pow(10,s.size()-1-i);
	}
	return res;
}

bool findx(string s){
	rep(i,s.size())if(s[i]=='X')return true;
	return false;
}

int main(){
	string s;
	int ans;
	while(cin>>s){
		string alt="";
		vector<string> vec;
		rep(i,s.size()){
			if(i==s.size()-1){
				alt+=s[i];
				vec.push_back(alt);
			}else if(s[i]=='+' || s[i]=='='){
				vec.push_back(alt);
				alt="";
			}else alt+=s[i];
		}
		bool check=true;
		rep(i,9){
			vector<int> num;
			rep(j,3){
				if(findx(vec[j])){
					num.push_back(lackstoi(vec[j],i));
				}else{
					num.push_back(stoi(vec[j]));
				}
			}
			if((num[0]+num[1])==num[2]){
				check=false;
				ans=i;
				break;
			}
		}
		if(check)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}