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

int assignX(string s, int x) {
	replace(s.begin(), s.end(), 'X', (char)(x+'0'));
	return stoi(s);
}


int main () {
	string s;

	while(cin >> s) {
		int eq   = s.find("=");
		int plus = s.find("+");
		int ans = -1;

		string x = s.substr(0, plus);
		string y = s.substr(plus + 1, eq - plus - 1);
		string r = s.substr(eq + 1);

		for (int i = 0; i <= 9; i++) {
			if (i == 0 && (
				x.at(0) == 'X'
				|| y.at(0) == 'X'
				|| r.at(0) == 'X'
			)) {
				continue;
			}
			if (assignX(x, i) + assignX(y, i) == assignX(r, i)) {
				ans = i;
				break;
			}
		}
		cout << ((ans < 0) ? "NA" : to_string(ans)) << endl;
	}
	return 0;
}
