#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string a="sdghjkl";
	while (cin >> a) {
		int d, e = 0;
		a += "+";
		string l="";
		for (int i = 0; i < 10; i++) {
			string h = "",b[3];
			int  c = 0;
			string f = "", o = "";
			for (int j = 0; j < a.size(); j++) {
				if (a[j] == '+' || a[j] == '=') {
					if (h[0] == '0'&&h.length()!=1) goto stop;
					b[c]= h;
					c++;
					h = "";
				}
				else {
					if (a[j] == 'X')
						h += to_string(i);
					else
						h += a[j];
				}
			}
			f=b[0];
			for (int j = b[0].size()-1; j >=0; j--) 
				f[b[0].length() - 1-j] = b[0][j];
			b[0] = f;
			f = b[1];
			for (int j = b[1].size() - 1; j >= 0; j--)
				f[b[1].length() - 1 - j] = b[1][j];
			b[1] = f;
			f = "";
			bool g= false;
			for (int j = 0; j < max(b[0].size(), b[1].size()); j++) {
				if (j < b[0].size() && j < b[1].size()) {
					int k = (int)b[0][j] - '0' + b[1][j] - '0';
					if (g) {
						k++;
						g = false;
					}
					if (k >= 10) {
						k -= 10; g = true;
					}
					f += to_string(k);
				}
				else if (j < b[0].size()) {
					int k = (int)b[0][j] - '0';
					if (g) {
						k++;
						g = false;
					}
					if (k >= 10) {
						k -= 10;
						g = true;
					}
					f += to_string(k);
				}
				else {
					int k = (int)b[1][j] - '0';
					if (g) {
						k++;
						g = false;
					}
					if (k >= 10) {
						k -= 10;
						g = true;
					}
					f += to_string(k);
				}
			}
			if(g) f+="1";
			o = "";
			for (int i = f.length() - 1; i >= 0; i--)
				h += f[i];
			f = h;
			if (f == b[2]) {
				l = to_string(i);
				e++;
				break;
			}
		stop:;
		}
		if (e==0)
			cout << "NA" << endl;
		else
			cout << l << endl;
	}
}