#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	while (cin >> s) {
		int v[5] = {}, x[5] = {}, p = 1, b = 0;
		for (int i = 1; i <= 3; i++) { v[i] = 0; x[i] = 0; }
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '+' || s[i] == '=')p++;
			else {
				v[p] *= 10; x[p] *= 10;
				if (s[i] == 'X') { if (!v[p] && !x[p])b = 1; x[p]++; }
				else v[p] += s[i] - '0';
			}
		}
		for (int i = b; i <= 9; i++) {
			if (v[1] + v[2] + (x[1] + x[2])*i == v[3] + x[3] * i) {
				cout << i << endl;
				goto heaven;
			}
		}
		cout << "NA\n";
	heaven:;
	}
	return 0;
}
