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

int func(string s, int n){
	int a = 1, ans = 0;
	for(int i = s.size()-1;i >= 0;i--){
		if(s[i] == 'X')ans += n * a;
		else ans += (s[i]-'0') * a;
		a *= 10;
	}
	return ans;
}

int check(string s1, string s2, string s3){
	if(s1.size() > 1 && s1[0] == 'X')return 1;
	if(s2.size() > 1 && s2[0] == 'X')return 1;
	if(s3.size() > 1 && s3[0] == 'X')return 1;
	return 0;
}

int sub(string s1, string s2, string s3){
	for(int i= 0;i < 10;i++){
		if(!i && check(s1, s2, s3))continue;
		int n1 = func(s1, i);
		int n2 = func(s2, i);
		int n3 = func(s3, i);
		//cout << n1 << " " << n2 << " " << n3 << endl;
		if(n1 + n2 == n3){cout << i;return 1;}
	}
	return 0;
}

int main(){
	string str, s1, s2, s3;
	while(cin >> str){
		s1 = s2 = s3 = "\0";
		int p = 0;
		for(p;str[p] != '+';p++)s1 += str[p];p++;
		for(p;str[p] != '=';p++)s2 += str[p];p++;
		for(p;p < str.size();p++)s3 += str[p];
		
		if(!sub(s1, s2, s3))cout << "NA";cout << endl;
	}
	return 0;
}