#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

string add(string a, string b) {

	int za = a.size();
	int zb = b.size();
	vector<int>v;

	for (int i = 0; i < max(za, zb); i++) {
		if (i < min(za, zb)) {
			int c = za - i - 1;
			int d = zb - i - 1;
			v.push_back((a[za - i - 1] - '0') + (b[zb - i - 1] - '0'));
		}
		else {
			if (za < zb)v.push_back(b[zb - i - 1] - '0');
			else v.push_back((a[za - i - 1]) - '0');
		}
	}
	int z = v.size();
	for (int i = 0; i < v.size(); i++) {
		if (i != z - 1 && v[i] >= 10) {
			v[i] -= 10;
			v[i + 1]++;
		}
	}
	string ans = "";
	for (int i = z - 1; i > -1; i--) {
		int x = v[i];
		string c = to_string(x);
		ans += c;
	}
	return ans;
}

int main() {
	string a;
	while (cin >> a) {
		string sa, sb, sc;
		vector<string>VA,VB,VC;
		
		int h = 0;
		for (int i = 0; i < a.size(); i++) {
			if (a[i] == '+')h = 1;
			else if (a[i] == '=')h = 2;
			else {
				if (h == 0)sa.push_back(a[i]);
				else if (h == 1)sb.push_back(a[i]);
				else sc.push_back(a[i]);
			}
		}

		for (int i = 0; i <= 9; i++) {
			string A, B, C;
			for (int j = 0; j < sa.size(); j++) {
				if (sa[j] == 'X') {
					char x = '0' + i;
					A.push_back(x);
				}
				else A.push_back(sa[j]);
			}

			for (int j = 0; j < sb.size(); j++) {
				if (sb[j] == 'X') {
					char x = '0' + i;
					B.push_back(x);
				}
				else B.push_back(sb[j]);
			}

			for (int j = 0; j < sc.size(); j++) {
				if (sc[j] == 'X') {
					char x = '0' + i;
					C.push_back(x);
				}
				else C.push_back(sc[j]);
			}
			if ((A[0] != '0'||A.size()==1)&&(B[0] != '0'||B.size()==1)&&(C.size()==1||C[0] != '0')) {
				VA.push_back(A);
				VB.push_back(B);
				VC.push_back(C);
			}
		}
		int ans = -1;
		for (int i = 0; i < VA.size(); i++) {
			if (add(VA[i], VB[i]) == VC[i]) {
				if (VA.size() == 10)ans = i;
				else ans = i + 1;
			}
		}
		if (ans == -1)cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}