#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <map>
using namespace std;

void tokenize(string &s, const string &token){
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < token.size(); j++){
			if(s[i] == token[j]){
				s[i] = ' ';
			}
		}
	}
}

void replaceX(string &s, int x){
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'X'){
			s[i] = '0'+x;
		}
	}
}

bool check(const string &s){
	stringstream ss;
	ss << s;
	int a[3];
	string tmp;
	for(int i = 0; i < 3; i++){
		ss >> tmp;
		if(tmp.size() > 1 && tmp[0] == '0'){
			return false;
		}
		a[i] = atoi(tmp.c_str());
	}

	return a[0]+a[1] == a[2];
}

int main(){
	string s;
	string token = "+=";

	while(cin >> s){
		stringstream ss;
		tokenize(s, token);
		int n = -1;
		for(int i = 0; i <= 9; i++){
			string t = s;
			replaceX(t, i);
			if(check(t)){
				n = i;
			}
		}
		if(n == -1){
			cout << "NA" << endl;
		}else{
			cout << n << endl;
		}
	}

	return 0;
}