#include <bits/stdc++.h>

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

using namespace std;





int main()
{
	string s;
	while(cin >>s){
	
		bool ok=0;
		rep(i,10){
			auto w=s;
			replace(w.begin(),w.end(),'X',char(i+'0'));
			rep(j,10){
				string no = string(1, char(j+'0'));
				if( w.find("+0"+no)!=-1 || w.find("=0"+no)!=-1) w="00";
				if(w[0]=='0' && w[1]==char(j+'0')) w="00";
			}
			if(w=="00") continue;
			
			//cout << w << " :: ";
			int64_t sm=0, sm2=0;
			for(auto x: w){
				if(isdigit(x)) sm2=sm2*10+x-'0';
				else{
					sm += sm2;
					sm2 = 0;
				}
			}
			//cout <<sm <<"  "<<sm2 <<"\n";
			if(sm == sm2){
				cout << i << "\n";
				ok=1; break;
			}
		}
		if(!ok) cout <<"NA\n";
	
	}
	
	return 0;

}