#include <string>
#include <iostream>

using namespace std;

bool ok(string s)
{
	long long cnt = 0, num[3] = {0};
	for (auto c : s){
		if (c == '+' || c == '='){
			cnt++;
			continue;
		}
		num[cnt] *= 10;
		num[cnt] += (c - '0');
	}

	return ((num[0] + num[1]) == num[2]);
}

int main(void)
{
	string str;

	while (cin >> str){
		for (int i = 0; i < 10; i++){
			string s = str;
			for (auto &c : s){
				if (c == 'X'){
					c = i + '0';
				}
			}
			if (ok(s)){
				cout << i << endl;
				goto END;
			}
		}
		cout << "NA" << endl;
		END:;
	}

	return 0;
}