#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string tmp;
	while(cin>>tmp){
		rep(i,10){
			string s=tmp;
			int a,b;
			rep(j,s.size()){
				if(s[j]=='X')s[j]=(char)(i+'0');
				if(s[j]=='+')a=j;
				if(s[j]=='=')b=j;
			}
			//3 7
			string s1=s.substr(0,a),s2=s.substr(a+1,b-a-1),s3=s.substr(b+1);
			if(s1[0]=='0'||s2[0]=='0'||s3[0]=='0')continue;
			int a1=atoi(&s1[0]),a2=atoi(&s2[0]),a3=atoi(&s3[0]);
			if(a1+a2==a3){cout<<i<<endl;break;}
			if(i==9)cout<<"NA"<<endl;
		}
	}
}