#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		string Num[3];
		int count = 0;
		int n = str.size();
		for(int i = 0; i < n; ++i)
		{
			if(str[i] == '+' || str[i] == '=')
			{
				++count;
				continue;
			}
			Num[count] += str[i];
		}
		bool Flag = false;
		for(int i = 0; i < 10; ++i)
		{
			string Try[3];
			for(int j = 0; j < 3; ++j)
			{
				int size = Num[j].size();
				for(int k = 0; k < size; ++k)
				{
					if(Num[j][k] == 'X')
					{
						Try[j] += i + '0';
					}
					else
					{
						Try[j] += Num[j][k];
					}
				}
			}
			if(atoi(Try[0].c_str()) + atoi(Try[1].c_str()) == atoi(Try[2].c_str()))
			{
				cout << i << endl;
				Flag = true;
				break;
			}
		}
		if(!Flag)
		{
			cout << "NA" << endl;
		}
	}
}

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