#include <iostream>
#include <string>

using namespace std;

int len;
string S;

bool isok(string s) {
	int a = 0, b = 0, c = 0;
	
	int i = 0;
	while (s[i] != '+') a = 10 * a + (s[i++] - '0');
	i++;
	while (s[i] != '=') b = 10 * b + (s[i++] - '0');
	i++;
	while (i < len) c = 10 * c + (s[i++] - '0');
	
	return (a + b) == c;
}

void solve() {
	for (int x = 0; x <= 9; x++) {
		string s = S;
		
		for (int i = 0; i < len; i++) {
			if (s[i] == 'X') {
				s[i] = ('0' + x);
			}
		}
		
		if (isok(s)) {
			cout << x << endl;
			return;
		}
	}
	
	cout << "NA" << endl;
}

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