#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
typedef string::const_iterator State;

//数字の列をパースして、その数を返す
ll number(State &begin){
	ll ret =0;
	while(isdigit(*begin)){
		ret *=10;
		ret += *begin-'0';
		begin++;
	}
	return ret;
}

int main(){
	string str;
	while(cin>>str){
		bool flag =false;
		for(int j ='0';j <='9'&&!flag;j++){
			string tmp =str;
			bool zero =true;
			if(tmp[0]=='X'&&j=='0'&&tmp.size()>=2)continue;
			for(int i =0;i <str.length()&&!flag;i++){
				if(tmp[i]=='X'){
					tmp[i]=j;
				}
				if(tmp[i]=='+'){
					if(tmp[i+1]=='X'&&isdigit(tmp[i+2])&&j==0){
						zero =false;
						break;
					}
				}
				if(tmp[i]=='='){
					if(tmp[i+1]=='X'&&tmp.length()-i>=2&&j==0){
						zero =false;
						break;
					}
				}
			}
			if(!zero)continue;
			State begin =tmp.begin();
			ll a =number(begin);
			begin++;
			ll b =number(begin);
			begin++;
			ll c =number(begin);
			//printf("a = %d b =%d c =%d\n",a,b,c);
			if(a+b==c){
				flag =true;
				printf("%c\n",j);
			}
		}
		if(!flag)cout <<"NA"<<endl;
		
	}
	return 0;
}