#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		string a, b, c;
		int size = str.size();
		int pos = 0;
		while(str[pos] != '+')
		{
			a += str[pos];
			++pos;
		}
		++pos;
		while(str[pos] != '=')
		{
			b += str[pos];
			++pos;
		}
		++pos;
		for(int i = pos; i < size; ++i)
		{
			c += str[i];
		}
		int size_a = a.size();
		int size_b = b.size();
		int size_c = c.size();
		for(int i = 0; i < 10; ++i)
		{
			unsigned long long int A = 0, B = 0, C = 0;
			unsigned long long int temp = 1;
			string use_a = a;
			for(int j = size_a - 1; j >= 0; --j)
			{
				if(use_a[j] == 'X')
				{
					use_a[j] = i + '0';
				}
				A += (use_a[j] - '0') * temp;
				temp *= 10;
			}
			temp = 1;
			string use_b = b;
			for(int j = size_b - 1; j >= 0; --j)
			{
				if(use_b[j] == 'X')
				{
					use_b[j] = i + '0';
				}
				B += (use_b[j] - '0') * temp;
				temp *= 10;
			}
			temp = 1;
			string use_c = c;
			for(int j = size_c - 1; j >= 0; --j)
			{
				if(use_c[j] == 'X')
				{
					use_c[j] = i + '0';
				}
				C += (use_c[j] - '0') * temp;
				temp *= 10;
			}
			if(A + B == C)
			{
				cout << i << endl;
				goto NEXT;
			}
		}
		cout << "NA" << endl;
NEXT:
		;
	}
}

int main()
{
	solve();
	return(0);
}