#include <iostream>
#include <vector>
#include <cctype>
#include <string>
#include <algorithm>
using namespace std;

void print_v(vector<int> vi){
	for(int i = 0; i < vi.size(); i++){
		cout << vi[i];
	}
	cout << endl;
}

vector<int> get_num(string &s, int k){
	vector<int> num;
	for(size_t i = 0; i < s.size(); i++){
		if(s[i] == 'X'){
			num.push_back(k);
		}else{
			num.push_back(s[i] - '0');
		}
	}
	return num;
}

vector<int> sum(vector<int> num1, vector<int> num2){
	vector<int> num3;
	reverse(num1.begin(), num1.end());
	reverse(num2.begin(), num2.end());
	while(num1.size() < num2.size()) num1.push_back(0);
	while(num2.size() < num1.size()) num2.push_back(0);
	int c = 0;
	int d = 0;
	for(size_t i = 0; i < num1.size(); i++){
		d = c + num1[i] + num2[i];
		c = d / 10;
		d %= 10;
		num3.push_back(d);
	}
	if(c == 1) num3.push_back(c);
	reverse(num3.begin(), num3.end());
	return num3;
}

int main(){
	string s;
	while(cin >> s){
		int i = 0, j;
		while(s[i] != '+') i++;
		string num1(s.begin(), s.begin() + i);
		i++;
		j = i;
		while(s[j] != '=') j++;
		string num2(s.begin() + i, s.begin() + j);
		j++;
		string num3(s.begin() + j, s.end());
		bool f = false;
		if((num1[0] == 'X' && num1.size() > 1) || (num2[0] == 'X' && 
			num2.size() > 1) || (num3[0] == 'X' && num3.size() > 1)) f = true;
		if((num1[0] == '0' && num1.size() > 1) || (num2[0] == '0' &&
			num2.size() > 1) || (num3[0] == '0' && num3.size() > 1)){
			cout << "NA" << endl;
			continue;
		}
		int k = 0;
		while(k < 10){
			if(f){
				k++;
				f = false;
				continue;
			}
			vector<int> n1, n2, n3, n4;
			n1 = get_num(num1, k);
			n2 = get_num(num2, k);
			n3 = get_num(num3, k);
			n4 = sum(n1, n2);
			bool ok = true;
			if(n3.size() != n4.size()){
				ok = false;
			}else{
				for(size_t i = 0; i < n3.size(); i++){
					if(n3[i] != n4[i]){
						ok = false;
						break;
					}
				}
			}
			if(ok) break;
			k++;
		}
		if(k < 10) cout << k << endl;
		else cout << "NA" << endl;
	}
	return 0;
}