#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		vector<int> v;
		int ans=-1;
		for(int i=0;i<s.size();++i) if(s[i]=='X')v.push_back(i);
		for(int i=0;i<10;++i){
			for(int j=0;j<v.size();++j){
				s[v[j]]=i+'0';
			}
			int a,b,c;
			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;
}