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

using namespace std;

int AlphameticReplace(string &s, int r, char X){
	for(unsigned int i = 0; i < s.length(); i++){
		if( s[i] == X ) s[i] = r + '0';
	}
	return atoi(s.c_str());
}

int main(void){
	while( true ){
		int ans;
		bool bFound = false;
		int ia, ib, ic;
		string s,a,b,c;
		cin >> s;
		if( cin.eof() ) break;
		a = s.substr(0, s.find('+'));
		b = s.substr(s.find('+')+1, s.find('=') - (s.find('+')+1));
		c = s.substr(s.find('=')+1);

		for(int x = 0; x < 10; x++){
			string ta = a, tb = b, tc = c;
			ia = AlphameticReplace(ta, x, 'X');
			ib = AlphameticReplace(tb, x, 'X');
			ic = AlphameticReplace(tc, x, 'X');
			if( ia + ib == ic ){
				ans = x;
				bFound = true;
			}
		}
		if( bFound ){
			cout << ans << '\n';
		}else{
			cout << "NA\n";
		}
	}
	return 0;
}