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

using namespace std;

int len;
string S;
string a, b, c;

void convert() {
	a = b = c = "";
	int i = 0;
	while (S[i] != '+') a += S[i++];
	i++;
	while (S[i] != '=') b += S[i++];
	i++;
	while (i < len) c += S[i++];
}

void solve() {
	for (int x = 0; x <= 9; x++) {
		int A = 0, B = 0, C = 0;
		
		for (int i = 0; i < (int)a.size(); i++) {
			if (a[i] == 'X') A = 10 * A + x;
			else A = 10 * A + (a[i] - '0');
		}
		
		for (int i = 0; i < (int)b.size(); i++) {
			if (b[i] == 'X') B = 10 * B + x;
			else B = 10 * B + (b[i] - '0');
		}
		
		for (int i = 0; i < (int)c.size(); i++) {
			if (c[i] == 'X') C = 10 * C + x;
			else C = 10 * C + (c[i] - '0');
		}
		
		if (x == 0) {
			if ((int)a.size() > 1) {
				stringstream as;
				as << A;
				if ((int)a.size() != (int)as.str().size()) continue;
			}
			if ((int)b.size() > 1) {
				stringstream as;
				as << B;
				if ((int)b.size() != (int)as.str().size()) continue;
			}
			if ((int)c.size() > 1) {
				stringstream as;
				as << C;
				if ((int)c.size() != (int)as.str().size()) continue;
			}
		}
		
		if (A + B == C) {
			cout << x << endl;
			return;
		}
	}
	
	cout << "NA" << endl;
}

int main() {
	while (cin >> S) {
		len = S.size();
		convert();
		solve();
	}
	
	return 0;
}