#include<iostream>
#include<string>
#include<vector>
using namespace std;

int stoi(string s){
  int res = 0 ;
  //for(int i = s.size() - 1 ; i >= 0 ; i --){
  for(int i = 0 ; i < s.size() ; i ++){ 
    res = s[i] - '0' + res * 10;
  }
  return res;
}
int main(void){
  string in;
  while(getline(cin,in)){
    string f,s,r;
    vector<int> ff,ss,rr;
    f = s = r = "";
    int i;
    in += "n";
    for(i = 0 ; in[i] != '+' ; i ++){
      f += in[i];
      if(in[i] == 'X')ff.push_back(i);
    }
    i ++;
    for(; in[i] != '=' ; i ++){
      s += in[i];
      if(in[i] == 'X')ss.push_back(i - f.size() - 1);
    }
    i ++;
    for(; in[i] != 'n' ; i ++){
      r += in[i];
      if(in[i] == 'X')rr.push_back(i - f.size() - s.size() - 2);
    }
    /*
    cout<<"FF";
    for(int  i = 0 ; i < ff.size() ; i ++)cout<<ff[i]<<" ";
    cout<<endl;
    /*
    cout<<"ss";
    for(int  i = 0 ; i < ss.size() ; i ++)cout<<ss[i]<<" ";
    cout<<endl;
    cout<<"rr";
    for(int  i = 0 ; i < rr.size() ; i ++)cout<<rr[i]<<" ";
    cout<<endl;
    cout<<f<<" "<<s<<" "<<r<<endl;
    */
    bool ans = false;
    for(int i = 0 ; i < 10 ; i ++){
      for(int j = 0 ; j < ff.size() ; j ++){
	f[ff[j]] = i + '0';
      }
      for(int j = 0 ; j < ss.size() ; j ++){
	s[ss[j]] = i + '0';
      }
      for(int j = 0 ; j < rr.size() ; j ++){
	r[rr[j]] = i + '0';
      }
      if(stoi(r) == stoi(s) + stoi(f)){
	cout<<i<<endl;
	ans = true;
	break;
      }
      //cout<<stoi(r) <<" "<<  stoi(s) <<" "<< stoi(f)<<endl;
      //cout<<r<<" "<<f<<" "<<s<<endl;
    }
    if(!ans)cout<<"NA"<<endl;
  }
}