#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,2,0,-2,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0,2,0,-2};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
bool compare(string a,string b){
    if(b.size() > a.size())return true;
    if(b.size() < a.size())return false;
    rep(i,a.size()){
        if(b[i] > a[i])return true;
        if(b[i] < a[i])return false;
    }
    return false;
}
string long_calc_p(string a,string b){
    string ans = "";
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    int sz;
    int mi;
    if(a.size() > b.size()){
        sz = a.size();
        mi = b.size();
    }
    else{
        sz = b.size();
        mi = a.size();
    }
    int carry = 0;
    rep(i,sz){
        if(i >= mi){
            if(mi == a.size()){
                int tmp = b[i]-'0'+carry;
                if(tmp > 9){
                    carry = 1;
                    ans += tmp-10+'0';
                }
                else{
                    carry = 0;
                    ans += tmp+'0';
                }
            }
            else{
                int tmp = a[i]-'0'+carry;
                if(tmp > 9){
                    carry = 1;
                    ans += tmp-10+'0';
                }
                else{
                    carry = 0;
                    ans += tmp+'0';
                }
            }
        }
        else{
            int tmp = a[i]-'0'+b[i]-'0'+carry;
            if(tmp > 9){
                carry = 1;
                ans += tmp-10+'0';
            }
            else{
                carry = 0;
                ans += tmp+'0';
            }
        }
    }
    if(carry)ans+="1";
    reverse(ans.begin(),ans.end());
    return ans;
}
void getX(string str, vi &a){
	rep(i,str.size()){
		if(str[i] == 'X'){
			a.PB(i);
		}
	}
	return ;
}
string setNum(string str,vi a,int n){
	
	rep(i,a.size()){
		str[a[i]] = n+'0';
	}
	return str;
}
int main(){
	string str;
	while(cin >> str){
		string s1="",s2="",s3="";
		int index = 0;
		for( ; str[index] != '+' ; index++){
			s1 += str[index];
		}
		index++;
		for( ; str[index] != '=' ; index++){
			s2 += str[index];
		}
		index++;
		for( ; index < str.size() ; index++){
			s3 += str[index];
		}

		vi a,b,c;

		getX(s1,a);
		getX(s2,b);
		getX(s3,c);

		int ans = -1;
		rep(i,10){
			if(long_calc_p(setNum(s1,a,i),setNum(s2,b,i)) == setNum(s3,c,i)){
				ans = i;
				break;
			}
		}
		if(ans == -1)puts("NA");
		else printf("%d\n",ans);
	}
    return 0;
}