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

int to_i(string s) {
	istringstream is(s);
	int n;
	is >> n;
	return n;
}

bool valid(string s) {
	int i = 0;
	string a, b, sum;
	while (s[i] != '+') {
		a.push_back(s[i++]);
	}
	i++;
	while (s[i] != '=') {
		b.push_back(s[i++]);
	}
	i++;
	while (i < s.size()) {
		sum.push_back(s[i++]);
	}
	if (a[0] == '0' || b[0] == '0' || sum[0] == '0') {
		return false;
	}
	return to_i(a) + to_i(b) == to_i(sum);
}

int main() {
	string s;
	while (cin >> s) {
		bool exist = false;
		for (int i = 0; i <= 9; i++) {
			string t = s;
			for (int j = 0; j < t.size(); j++) {
				if (t[j] == 'X') {
					t[j] = i + '0';
				}
			}
			if (valid(t)) {
				cout << i << endl;
				exist = true;
				break;
			}
		}
		if (!exist) {
			cout << "NA" << endl;
		}
	}
	return 0;
}