#include <iostream>
#include <algorithm>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

void x2n (string & s, int n )
{
	string cn = itos (n );
	while (s.find ('X' ) != string::npos ){
		s = s.replace(s.find('X'), 1, cn );
	} // end while
}

string longlongadd (string str1, string str2 )
{
	string res = "";
	
	reverse (str1.begin(), str1.end() );
	reverse (str2.begin(), str2.end() );
	int len1 = str1.length();
	int len2 = str2.length();

	while (len1 != len2 ){
		if (len1 < len2 ){
			str1 += '0';
			len1 = str1.length();
		}else if (len1 > len2 ){
			str2 += '0';
			len2 = str2.length();
		} // end if
	} // end while

	bool carry = false;
	for (int i = 0; i < len1; i++ ){
		int num1 = str1[i] - '0';
		int num2 = str2[i] - '0';
		int sum = num1 + num2;

		sum += (carry ? 1 : 0 );

		if (sum < 10 ){
			res += sum + '0';
			if (carry){
				carry = false;
			} // end if
		}else{
			sum %= 10;
			res += sum + '0';
			carry = true;
		} // end if
	} // end for

	if (carry){
		res += '1';
	} // end if

	reverse (res.begin(), res.end());

	return res;
}

int main()
{
	string str = "";
	while (cin >> str ){
		string a = str.substr (0, str.find('+') );
		string b = str.substr (str.find ('+' )+1, str.find ('=' ) - str.find('+') - 1);
		string c = str.substr (str.find ('=')+1 );
		bool found = false;
		for (int i = 0; i < 10;  i++ ){
			string ca = a, cb = b, cc = c;
			x2n (ca, i ), x2n(cb, i ), x2n (cc, i );
			string add = longlongadd (ca, cb );
			if (add == cc ){
				cout << i << endl;
				found = true;
			} // end if
		} // end for
		if (!found ){
			cout << "NA" << endl;
		} // end if		
	} // end loop
		
	return 0;
}