#include<iostream>
using namespace std;

int stoi(string a){
  int tmp,res;
  tmp = 1;
  res = 0;
  while(a.size()){
    res += (a[a.size()-1] - '0') * tmp;
    a.erase(a.end()-1);
    tmp*=10;
  }
  return res;
}


int main(){
  string str,tmp;
  string a,b,c;
  int d,e,f;
  int mode;
  int i,j;

  while(cin >> str){
    for(i=0;i<10;i++){
      tmp = str;
      for(j=0;j<tmp.size();j++){
	if(tmp[j]=='X')tmp[j] = '0' + i;
      }
      a.clear();
      b.clear();
      c.clear();
      mode = 0;
      for(j=0;j<tmp.size();j++){
	if(tmp[j] == '+'){
	  mode++;
	}else if(tmp[j] == '='){
	  mode++;
	}else{
	  if(mode==0)a.push_back(tmp[j]);
	  else if(mode==1)b.push_back(tmp[j]);
	  else c.push_back(tmp[j]);
	}
      }
      d = stoi(a);
      e = stoi(b);
      f = stoi(c);
      if(d+e == f){
	cout << i << endl;
	break;
      }
    }
    if(i==10)cout << "NA" << endl;
  }
}