#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;
}

bool 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 + C) % 10 != sp[2][i] - '0') return false;
		C = sum / 10;
	}

	return true;
}

int main(){
	string s;
	while(cin >> s){
		rep(i,s.size()) if(s[i] == '+') s[i] = '=';
		vector<string> sp = split(s, '=');

		int start = 0;
		for(auto& i : sp) if(i.front() == 'X' and i.size() > 1) start = 1;
		for(auto& i : sp) reverse(all(i));
		for(auto& i : sp) while(i.size() <= 130) i.push_back('0');

		bool f = false;
		range(i,start,10){
			if(checkValidation(sp, i)){
				cout << i << endl;
				f = true;
			}
		}
		if(not f) cout << "NA" << endl;
	}
}

