#include <iostream>
#include <string>
#include <sstream>
#include <cmath>

using namespace std;

bool debug = false;

class Masked{
 public:
  double base;
  double mask;
  
  double evalwith(int n){
	return base + mask * n;
  }
};

Masked parse(string str){
  Masked ret;
  
  if(debug) cout << "parsing " << str << endl;

  ret.base=0;
  ret.mask=0;
  for(int i=0;i<str.size(); i++){
	if(str[str.size()-i-1] == 'X'){
	  ret.mask += pow(10,i);
	}else{
	  ret.base += pow(10,i) * (str[str.size()-i-1] - '0');
	}
  }
  if(debug) cout << "parsed. base = " << ret.base << ", masked = " << ret.mask << endl;

  return ret;
}

int main(void){
  string str;
  Masked num[3];

  while(getline(cin,str)){
	string tmp="";
	bool exist = false;
	for(int i=0;i<str.size();i++){
	  if(str[i] == '+'){
		num[0] = parse(tmp);
		tmp.clear();
	  }else if(str[i] == '='){
		num[1] = parse(tmp);
		tmp.clear();
	  }else{
		tmp += str[i];
	  }
	}
	num[2] = parse(tmp);

	for(int i=0;i<=9;i++){
	  if(debug) cout << num[0].evalwith(i) << " + " << num[1].evalwith(i) << " = " << num[2].evalwith(i) << endl;
	  if(num[0].evalwith(i) + num[1].evalwith(i) - num[2].evalwith(i) < 1){
		cout << i << endl;
		exist = true;
	  }
	}
	if(!exist) cout << "NA" << endl;
  }

}