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

typedef std::vector< std::string > vs;
std::string BigIntegerSum( std::string str1, std::string str2 );

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;
}

template<class T>
std::string ToStr( T t ){
  std::stringstream ss;
  std::string str;
  ss<<t;
  ss>>str;
  
  return str;
}

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;
}

std::string 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 && s[l].size() != 1 && x == 0 )return "";
        s[l][i] = ToChar( x );
      }

  //std::cout<<res[0] <<"+"<< res[1]<<"="<<res[0]+res[1]<<std::endl;
  return BigIntegerSum( s[0], s[1] );
}
std::string RightCalc( std::string str, int x ){
  int res, pos = 0;
  while( ( res = str.find( "X", pos ) ) != std::string::npos ){
    if( res == 0 && str.size() != 1 && x == 0 )return "___";
    str[res] = ToChar( x );
    pos = res + 1;
  }
  //std::cout<<" "<<str<<std::endl;
  return str;
}

std::string BigIntegerSum( std::string str1, std::string str2 ){
  bool up = false;
  std::reverse( str1.begin(), str1.end() );
  std::reverse( str2.begin(), str2.end() );
  
  for( int i =0; i < std::max( str1.size(), str2.size() ) || up; ++i ){
    if( i >= str1.size() ) str1+='0';
    if( i >= str2.size() ) str2+='0';
    str1[i] += ToInt( str2[i] ) + up;
    up = false;
    if( str1[i] > '9' )str1[i]-=10, up = true;
  }
  std::reverse( str1.begin(), str1.end() );

  return str1;
}

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;
}