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

string gen(string str, char c)
{
	for (int i=0; i<str.size(); i++)
		if (str[i] == 'X')
			str[i] = c;

	return str;
}

bool check(string str)
{
	stringstream ss;
	int l=0, r=0, t;
	string n1, n2, n3;
	
	if (str[0] == '0') return false;
	int p = 0;
	while (str[p] != '+')
		p++;
	n1 = string(str.begin(), str.begin()+p);
	str = string(str.begin()+p+1, str.end());
	p = 0;
	if (str[0] == '0') return false;
	while (str[p] != '=')
		p++;
	if (str[p+1] == '0') return false;
	n2 = string(str.begin(), str.begin()+p);
	n3 = string(str.begin()+p+1, str.end());

	ss << n1;
	ss >> l;
	ss.clear();
	ss.str("");
	ss << n2;
	ss >> t;
	l += t;
	ss.clear();
	ss.str("");
	ss << n3;
	ss >> r;

	return l == r;
}

int main()
{
	string str;
	while (cin >> str)
	{
		bool f = 0;
		for (char c='0'; c<='9'; c++)
			if (check(gen(str, c)))
			{
				cout << c << endl;
				f = 1;
				break;
			}

		if (!f)
			cout << "NA" << endl;
	}
}