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

int main()
{
	string str, placedStr, lhv1,lhv2,rhv;
	int i;
	while(getline(cin, str))
	{
		for(i = 0; i < 10; ++i)
		{
			placedStr = str;
			int index = 0;
			while( (index = placedStr.find('X', index)) != string::npos)
			{
				placedStr[index] = i+'0';
				index++;
			}
			int a,b,c,ope1,ope2;
			ope1 = placedStr.find('+');
			ope2 = placedStr.find('=');

			lhv1 = placedStr.substr(0, ope1);
			lhv2 = placedStr.substr(ope1+1, ope2-ope1-1);
			rhv = placedStr.substr(ope2+1);

			if( (lhv1.size()>1&&lhv1[0] == '0') || 
				(lhv2.size()>1&&lhv2[0] == '0') ||
				(rhv.size()>1&&rhv[0] == '0') )
				continue;

			a = strtol(lhv1.c_str(), NULL, 10);
			b = strtol(lhv2.c_str(), NULL, 10);
			c = strtol(rhv.c_str(), NULL, 10);

			if(a+b == c)
			{
				cout << i << endl;
				goto END;
			}
		}
		cout << "NA" << endl;
END:
		;
	}
	return 0;
}