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

int get_num(string s, int k){
	int n = 0;
	for(size_t i = 0; i < s.size(); i++){
		if(isdigit(s[i])){
			n = n * 10 + s[i] - '0';
		}else{
			n = n * 10 + k;
		}
	}
	return n;
}

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' || num2[0] == 'X' || num3[0] == 'X') f = true;
		int k = 0;
		while(k < 10){
			if(f){
				f = false;
				continue;
			}
			int n1 = get_num(num1, k);
			int n2 = get_num(num2, k);
			int n3 = get_num(num3, k);
			if(n1 + n2 == n3) break;
			k++;
		}
		if(k < 10) cout << k << endl;
		else cout << "NA" << endl;
	}
	return 0;
}