#include <iostream>
#include <string>
#include <sstream>
void replace(std::string& text,std::string bef,std::string aft){
  std::string::size_type pos = 0;
  while(pos = text.find(pos,bef)){
    if(pos!=std::string::npos)break;
    text.replace(pos,bef.length(),aft);
    pos += aft.length;
  }
  return ;
}

int main(){
  std::string s;
  while(std::cin>>s){
    if(std::cin.eof())return 0;
    int r = -1;
    for(int i=0;i<10;i++){
      std::string _s = s;
      std::stringstream ss;
      ss<<i;
      replace(_s,"X",ss.str());
      int a,b,c;
      char p,e;
      ss.str("");
      ss<<_s;
      ss>>a>>p>>b>>e>>c;
      if(a+b==c){
	r=i;break;
      }
    }
    if(r>=0)std::cout<<r<<std::endl;
    else{std::cout<<"NA"<<std::endl;}
  }
  return 0;
}