#include <string>
#include <iostream>
#include <sstream>

using namespace std;

long long mstoll(string str)
{
	long long ret = 0;
	for (int i = 0; i < str.length(); i++){
		ret *= 10;
		ret += (str[i] - '0');
	}
	return ret;
}

bool ok(string s)
{
	// cout << s << endl;
	for (auto &c : s){
		if (c == '+' || c == '='){
			c = ' ';
		}
	}

	stringstream ss(s);
	string a, b, c;
	ss >> a >> b >> c;
	// cout << a << " " << b << " " << c << endl;
	if (a.length() >= 2u && a[0] == '0') return false;
	if (b.length() >= 2u && b[0] == '0') return false;
	if (c.length() >= 2u && c[0] == '0') return false;

	return ((mstoll(a) + mstoll(b)) == mstoll(c));
}

int main(void)
{
	string str;

	while (cin >> str){
		for (int i = 0; i < 10; i++){
			string s = str;
			for (auto &c : s){
				if (c == 'X'){
					c = i + '0';
				}
			}
			if (ok(s)){
				cout << i << endl;
				goto END;
			}
		}
		cout << "NA" << endl;
		END:;
	}

	return 0;
}