#include <iostream>
#include <string>
#include <sstream>
#include <vector>

typedef std::vector< std::string > vs;

std::string SubStr( std::string str, int x, int y ){
  return str.substr( x, y - x + 1 ); 
}

//cast functions
template<class T>
char ToChar( T t ){
  std::stringstream ss;
  char c;
  
  ss<<t;
  ss>>c;

  return c;
}
template<class T>
int ToInt( T t ){
  std::stringstream ss;
  int i;
  
  ss<<t;
  ss>>i;
  return i;
}


vs cut(std::string str){
  int res[2];
  vs s(3); 
  s[0] = SubStr( str, 0, ( res[0] = str.find( "+" ) ) -1  );
  s[1] = SubStr( str, res[0]+1, ( res[1] = str.find( "=" ) ) -1 );
  s[2] = SubStr( str, res[1]+1, str.size()-1 );
  
  return s;
}

int LeftCalc( vs s, int x ){
  int res[2] = { 0, 0 }, pos;
  
  int l = 2;
  while( l-- )
    for( int i = 0; i< s[l].size(); ++i )
      if( s[l][i] == 'X' ){
        if( i == 0 )return -1;
        s[l][i] = ToChar( x );
      }

  l = 2;
  while( l-- ){
    pos = 1;
    for( int i = s[l].size()-1; i >= 0; --i ){
      res[l] += pos * ToInt( s[l][i] );
      pos *= 10;
    }
  }
  //std::cout<<res[0] <<"+"<< res[1]<<"="<<res[0]+res[1]/*<<std::endl*/;
  return res[0] + res[1];
}
int RightCalc( std::string str, int x ){
  int res, pos = -1;
  while( ( res = str.find( "X", pos ) ) != std::string::npos ){
    if( res == 0 )return -2;
    str[res] = ToChar( x );
    pos = res + 1;
  }
  //std::cout<<" "<<str<<std::endl;
  return ToInt( str );
}
int main(){
  std::string str;
  vs cStr;
  int i;
  
  while( std::cin >> str ){
    cStr = cut( str );
    for( i = 0; i < 10; ++i ){
      vs s( 2 );
      s[0] = cStr[0], s[1] = cStr[1];
      //std::cout<<"Debug:79, "<<i<<std::endl;
      if( LeftCalc( s, i ) == RightCalc( cStr[2], i ) ){
        break;
      }
    }
    if( i == 10 )std::cout<<"NA"<<std::endl;
    else std::cout<< i <<std::endl;
  }
  return 0;
}