#include <iostream>
#include <sstream>

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

long long int 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));
  }

  std::stringstream ss;
  ss<<t;

  long long int res;
  ss>>res;

  return res;
}

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

    bool x0 = (a.find("X") == 0) || (b.find("X") == 0) || (c.find("X") == 0);

    int res = -1;
    for(int i=x0;i<=9;i++){
      //std::cout<<i<<std::endl;
      if(Xtoi(a,i)+Xtoi(b,i) == Xtoi(c,i)){res = i;break;}
    }

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