#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

vector<string> split(string in, char sp = ' '){
	vector<string> ret;
	stringstream ss(in);
	string s;
	while(getline(ss, s, sp)){
		ret.emplace_back(s);
	}
	return ret;
}

int getNumber(vector<string>& sp){
	rep(i,130){
		if(sp[0][i] == 'X' or sp[1][i] == 'X' or sp[2][i] == 'X'){
			int C = 0;
			if(i > 0 and sp[0][i - 1] - '0' + sp[1][i - 1] - '0' >= 10 ) C = 1;
			rep(k,10){
				int a = sp[0][i] == 'X' ? k : sp[0][i] - '0';
				int b = sp[1][i] == 'X' ? k : sp[1][i] - '0';
				int c = sp[2][i] == 'X' ? k : sp[2][i] - '0';
				if((a + b + C) % 10 == c){
					return k;
				}
			}
		}
	}
	return -1;
};

string checkValidation(vector<string>& sp, int ans){
	for(auto& v : sp){
		for(auto & c : v){
			if(c == 'X') c = '0' + ans;
		}
	}

	int C = 0;
	rep(i,130){
		int sum = sp[0][i] - '0' + sp[1][i] - '0';
		if(sum % 10 + C != sp[2][i] - '0') return "NA";
		C = sum / 10;
	}

	string ret = "0";
	ret[0] += ans;
	return ret;
}

int main(){
	string s;
	while(cin >> s){
		rep(i,s.size()) if(s[i] == '+') s[i] = '=';
		vector<string> sp = split(s, '=');
		for(auto& i : sp) reverse(all(i));
		for(auto& i : sp) while(i.size() <= 130) i.push_back('0');
		cout << checkValidation(sp, getNumber(sp)) << endl;
	}
}

