#include<iostream>

using namespace std;

int main(void) {
	string str;
	int dec[3], d, st;
	int i, j;

	while(true) {
		cin >> str;
		if(cin.eof()) { break; }

		if(str[0] == 'X') { st = 1; }
		else if(str.find("+X")!=string::npos) { st = 1; }
		else if(str.find("=X")!=string::npos) { st = 1; }
		else { st = 0; }

		for(i = st; i < 10; i++) {
			d = 0; dec[0] = 0;
			for(j = 0; j < (int)str.size(); j++) {
				if(str[j] == '+') { d = 1; dec[1] = 0; }
				else if(str[j] == '=') { d = 2; dec[2] = 0; }
				else if(str[j] == 'X') { dec[d] = dec[d] * 10 + i; }
				else { dec[d] = dec[d] * 10 + (str[j] - '0'); }
			}
			if(dec[0]+dec[1] == dec[2]) { break; }
		}

		if(i != 10) {
			cout << i << endl;
		} else {
			cout << "NA" << endl;
		}
	}

	return 0;
}