#include <algorithm>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::getline;
using std::replace;
using std::stoll;
using std::string;

bool x_is_right(string a,string b,string c,char x) {
	replace(a.begin(),a.end(),'X',x);
	replace(b.begin(),b.end(),'X',x);
	replace(c.begin(),c.end(),'X',x);
	return stoll(a) + stoll(b) == stoll(c);
}

int main() {
	string e; // expression
	while (getline(cin,e)) {
		auto ad_pos = e.find('+');
		auto eq_pos = e.find('=');
		string a = e.substr(0,ad_pos); // first number sequence
		string b = e.substr(ad_pos+1,eq_pos-ad_pos-1); // second number sequence
		string c = e.substr(eq_pos+1); // result number sequence
		string right_x = "";
		for (char x = '0';x <= '9';++x) {
			if (x_is_right(a,b,c,x)) {
				right_x.assign(1,x);
				break;
			}
		}
		cout << (right_x.empty() ? "NA" : right_x) << endl;
	}
}