#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		vector<int> v;
		int ans=-1,f=0;
		char A[3][128];
		sscanf(s.c_str(),"%[^+]+#[^=]=%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,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;
}