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

int Parse(string a) {
	int s = 0;
	for (int b = 0; b < a.length(); b++) {
		s *= 10;
		s += a[b] - 48;
	}
	return s;
}
int main() {
	string a;
	while (cin >> a) {
		for (int x = 0; x < 10; x++) {
			string b = a;
			for (int y = 0; y < a.length(); y++) {
				if (b[y] == 'X')b[y] = x+48;
			}
			vector<string>s;
			string c = "";
			for (int k = 0; k < b.length(); k++) {
				if (b[k] == '+' || b[k] == '=') { s.push_back(c); c = ""; }
				else c += b[k];
			}
			s.push_back(c);
			if (s[0][0] == '0' || s[1][0] == '0' || s[2][0] == '0')continue;
			if (Parse(s[0]) + Parse(s[1]) == Parse(s[2])) { cout << x << endl; break; }
			if (x == 9) { cout << "NA" << endl; break; }
		}
	}
}