#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <map>
using namespace std;

string strplus(string lhs, string rhs){
	string ret;
	reverse(lhs.begin(), lhs.end());
	reverse(rhs.begin(), rhs.end());
	while(lhs.size() > rhs.size()){
		rhs += '0';
	}
	while(lhs.size() < rhs.size()){
		lhs += '0';
	}
	int up = 0;
	for(int i = 0; i < lhs.size(); i++){
		int val = (lhs[i]-'0')+(rhs[i]-'0')+up;
		up = val/10;
		if(up){
			val-=10;
		}
		ret+=(val+'0');
	}
	if(up){
		ret+='1';
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

void tokenize(string &s, const string &token){
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < token.size(); j++){
			if(s[i] == token[j]){
				s[i] = ' ';
			}
		}
	}
}

void replaceX(string &s, int x){
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'X'){
			s[i] = '0'+x;
		}
	}
}

bool check(const string &s){
	stringstream ss;
	ss << s;
	string a[3];
	string tmp;
	for(int i = 0; i < 3; i++){
		ss >> a[i];
		if(a[i].size() > 1 && a[i][0] == '0'){
			return false;
		}
	}

	return a[2] == strplus(a[0], a[1]);
}

int main(){
	string s;
	string token = "+=";

	while(cin >> s){
		tokenize(s, token);
		int n = -1;
		for(int i = 0; i <= 9; i++){
			string t = s;
			replaceX(t, i);
			if(check(t)){
				n = i;
			}
		}
		if(n == -1){
			cout << "NA" << endl;
		}else{
			cout << n << endl;
		}
	}

	return 0;
}