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

int main(){

  long l_n, l_x, r_n, r_x, len, e, valid, zero;
  string str;
  
  while(cin >> str){
    len = str.length();
    l_n = 0;
    l_x = 0;
    r_n = 0;
    r_x = 0;
    valid = 0;
    e = 1;
    zero = 0;

    for(int i=len-1; i>=0; i--){
      if(valid == 0){
        if(str[i] != '='){
          if(str[i] == 'X'){
            r_x += e;
            if(str[i-1] == '=') zero = 1;
          }
          else{
            r_n += ((int)str[i] - '0') * e;
          }
          e *= 10;
        }
        else{
          valid = 1;
          e = 1;
        }
      }
      else{
        if(str[i] != '+'){
          if(str[i] == 'X'){
            l_x += e;
            if(i == 0 || str[i-1] == '+') zero = 1;
          }
          else{
            l_n += ((int)str[i] - '0') * e;
          }
          e *= 10;
        }
        else{
          e = 1;
        }
      }
    }

    for(int i=0; i<10; i++){
      if(i == 0 && zero == 1) continue;
      if(l_n + i * l_x == r_n + i * r_x){
        cout << i << endl;
        break;
      }
      if(i == 9){
        cout << "NA" << endl;
        break;
      }
    }

  }

  return 0;

}