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

int toNumber(string str)
{
	int i = 0;
	int r = 0;
	while ('0' <= str[i] && str[i] <= '9')
	{
		r *= 10;
		r += str[i] - '0';
		i++;
	}
	return r;
}

void split(string str, char v, string& substr1, string& substr2)
{
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == v)
		{
			substr1 = str.substr(0, i);
			substr2 = str.substr(i + 1, str.size() - i - 1);
			return;
		}
	}
}

bool isEqual(string str)
{
	string a, b, c, tmp;
	split(str, '+', a, tmp);
	split(tmp, '=', b, c);

	if (toNumber(a) + toNumber(b) == toNumber(c)) return true;
	return false;
}

int main()
{
	string str;
	while (cin >> str)
	{
		for (int i = 9; i >= 0; i--)
		{
			string s = str;
			replace(s.begin(), s.end(), 'X', char(i + '0'));
			if (isEqual(s))
			{
				cout << i << endl;
				break;
			}
			if (i == 0)
			{
				cout << "NA" << endl;
				break;
			}
		}
	}

	return 0;
}