#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int equal(string a,string b,string c){
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	reverse(c.begin(),c.end());
	a+='0';
	b+='0';
	c+='0';
	string a_b;
	char carry=0;
	int i;
	for(i=0;i<min(a.size(),b.size());++i){
		a_b+=(a[i]-'0'+b[i]-'0'+carry)%10+'0';
		carry=(a[i]-'0'+b[i]-'0'+carry)/10;
	}
	for(;a.size()!=b.size()&&i<max(a.size(),b.size());++i){
		a_b+=((a.size()>b.size())?a[i]:b[i]);
	}
	//cerr<<a_b<<","<<c<<endl;
	if(a_b==c)return 1;
	return 0;
}
int main(){
	string s;
	while(cin>>s){
		vector<int> v;
		int ans=-1,f=0;
		char A[3][128];
		sscanf(s.c_str(),"%[^+]%*c%[^=]%*c%s",A[0],A[1],A[2]);
		for(int i=0;i<3;++i) if(strlen(A[i])>1&&A[i][0]=='X') f=1;
		for(int i=0;i<s.size();++i) if(s[i]=='X') v.push_back(i);
		for(int i=f;i<10;++i){
			for(int j=0;j<v.size();++j){
				s[v[j]]=i+'0';
			}
			char a[128],b[128],c[128];
			sscanf(s.c_str(),"%[^+]%*c%[^=]%*c%s",a,b,c);
			string as,bs,cs;
			stringstream ss;
			ss<<a<<endl;ss>>as;
			ss<<b<<endl;ss>>bs;
			ss<<c<<endl;ss>>cs;
			//cerr<<as<<"+"<<bs<<"="<<cs<<endl;
			if(equal(as,bs,cs))ans=i;
		}
		if(ans!=-1) cout<<ans<<"\n";
		else cout<<"NA\n";
	}
	return 0;
}