#include<iostream>
#include<string>
#include<sstream>
using namespace std;

int main(){
	string str;
	while(cin >> str){
		int len = str.size();
		string num[3];
		int cou = 0;
		for(int i=0;i<len;i++){
			if(str[i] != '+' && str[i] != '='){
				num[cou] += str[i];
			}
			else cou++;
		}
		int flag = -1;
		string tmp;
		int ans[3];
		//istringstream ss;
		for(char i='0';i<='9';i++){
			bool f = false;
			for(int j=0;j<3;j++){
				int ll = num[j].size();
				tmp = num[j];
				for(int z=0;z<ll;z++){
					if(tmp[z] == 'X'){
						if(ll > 1 && z == 0 && i == '0') f=true;
						else tmp[z] = i;
					}
				}
				if(f) break;
				ans[j] = 0;
				istringstream ss(tmp);
				ss >> ans[j];
			}
			if(f) continue;
			if(ans[0]+ans[1] == ans[2]){
				string t = "";
				t += i;
				istringstream ss(t);
				flag = 0;
				ss >> flag;
				break;
			}
		}
		if(flag == -1) cout << "NA" << endl;
		else cout << flag << endl;
	}
}