#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

char s[200];
int main(){
	while(cin>>s){
		vector<string>v;
		char*split=strtok(s,"+=");
		do{
			v.push_back(string(split));
		}while(split=strtok(NULL,"+="),split);
		bool flag=true;
		rep(i,10){
			if((v[0][0]=='X'||v[1][0]=='X'||v[2][0]=='X')&&!i)continue;
			int cnt=0;
			rep(j,2){
				string S=v[j];
				replace(S.begin(),S.end(),'X',(char)(i+48));
				cnt+=stoi(S);
			}
			string S=v[2];
			replace(S.begin(),S.end(),'X',(char)(i+48));
			if(cnt==stoi(S)){
				cout<<i<<endl;
				flag=false;
				break;
			}
		}
		if(flag)puts("NA");
	}
}