#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	string str;
	while (cin >> str) {
		string exp;
		int flag = 0;
		for (int i = 0; i <= 9; i++) {
			exp = str;
			for (int j = 0; j < exp.size(); j++)
				if (exp[j] == 'X')
					exp[j] = i + '0';
			int a, b, c;
			sscanf(exp.c_str(), "%d+%d=%d", &a, &b, &c);
			if (a + b == c) {
				cout << i << endl;
				flag = 1;
				break;
			}
		}
		if (!flag)
			cout << "NA" << endl;
	}
	return 0;
}