#include <iostream>
#include <string>
#include <cstdlib>
#define lli long long int

using namespace std;

string func(string str, char v)
{
	int n = str.size();
	string st = "";
	
	for(int i = 0; i < n; i++){
		if(str[i] == 'X'){
			st += v;
		} else {
			st += str[i];
		}
	}
	
	return st;
}

int main()
{
	string str;
	
	while(cin>>str){
		string t1, t2, res;
		t1 = t2 = res = "";
		int s = 0;
		while(str[s] != '+'){
			t1 += str[s++];
		}
		s++;
		while(str[s] != '='){
			t2 += str[s++];
		}
		s++;
		while(s < str.size()){
			res += str[s++];
		}
		bool f = false;
		if(res[0] == 'X' || t1[0] == 'X' || t2[0] == 'X'){
			s = 1;
		} else {
			s = 0;
		}
		
		for(int i = s; i <= 9; i++){
			string v1 = func(t1, ((char)('0'+i)));
			string v2 = func(t2, ((char)('0'+i)));
			string r = func(res, ((char)('0'+i)));
			lli u1 = atoi(v1.c_str());
			lli u2 = atoi(v2.c_str());
			lli u3 = atoi(r.c_str());
			
			if(u1+u2 == u3){
				f = true;
				s = i;
				break;
			}
		}
		
		if(f){
			cout << s << endl;
		} else {
			cout << "NA" << endl;
		}
	}
}