#include <iostream>
#include <sstream>
#include <algorithm>

template<class T>
void dwrite(T o){
	std::cout << o << std::endl;
}

std::string itos(int i){
  std::stringstream ss;
  ss<<i;
  
  return ss.str();
}

std::string Xtoi(std::string s,int i){
  std::string t = s;
  int find;
  while(find = t.find("X"),find != std::string::npos){
    t.replace(find,1,itos(i));
  }

  return t;
}

//multiple-recision computation
std::string mpc(std::string a, std::string b){
	int n[50] = {0};
	std::reverse(a.begin(),a.end());
	std::reverse(b.begin(),b.end());

	for(int i=0;i<a.size();i++){
		n[i] = a[i] - '0';
	}
	for(int j=0;j<b.size();j++){
		n[j] += b[j] - '0';
	}
	for(int k=0;k<50;k++){
		if(n[k] >= 10){
			n[k] -= 10;
			n[k+1]++;
		}
	}
	int digit = 0;
	for(int l=49;l>=0;l--){
		if(n[l]){digit = l;break;}
	}
	
	std::string res = "";
	for(int i=0;i<=digit;i++){
		res = itos(n[i]) + res;
	}

	return res;
}

int main(){
  std::string s;

  while(std::cin>>s,!std::cin.eof()){
    int p = s.find("+"),e = s.find("=");
    std::string a = s.substr(0,p),b = s.substr(p+1,e-p-1),c = s.substr(e+1,s.size()-e-1);

    int x0 = !(a.find("X")) || !(b.find("X")) || !(c.find("X"));

    int res = -1;
    for(int i=x0;i<=9;i++){
			std::string t_a = Xtoi(a,i), 
				t_b = Xtoi(b,i), 
				t_c = Xtoi(c,i);
      if(!t_c.compare(mpc(t_a,t_b))){res = i;break;}
    }

    if(res>=0)std::cout<<res<<std::endl;
    else{std::cout<<"NA"<<std::endl;}
  }
}