#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	while (cin >> a) {
		int d, e = 0;
		a += "+";
		for (int i = 0; i < 10; i++) {
			string h = "";
			int b[3], c = 0;
			for (int j = 0; j < a.length(); j++) {
				if (a[j] == '+' || a[j] == '=') {
					if (h[0] == '0'&&h.length()!=1) goto stop;
					b[c] = atoi(h.c_str());
					c++;
					h = "";
				}
				else {
					if (a[j] == 'X')
						h += to_string(i);
					else
						h += a[j];
				}
			}
			if (b[0] + b[1] == b[2]) {
				d = i;
				e++;
			}
		stop:;
		}
		if (e==0)
			cout << "NA" << endl;
		else
			cout << d << endl;
	}
}