#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>

using namespace std;

string s,s1,s2,s3,temp1,temp2,temp3;
int cnt;
int S1,S2,S3;
bool TF;

void devide(void){
  
  for( int i = 0 ; s[i] != '+' ; i++ ){
    s1 = s1 + s[i];
    cnt++;
  }
  for( int i = cnt + 1 ; s[i] != '=' ; i++ ){
    s2 = s2 + s[i];
    cnt++;
  }
  for( int i = cnt + 2; i < s.size() ; i++ ){
    s3 = s3 + s[i];
  }
}

bool compute(void){

  if( S1 + S2 == S3 ) return true;
  else return false;

}


int change(void){
  
  
  for( int i = 0 ; i <= 9 ; i++ ){

    TF = false;

    for( int j = 0 ; j < s1.size() ; j++ ){
      if( s1[j] == 'X' ) temp1[j] = i + '0';
    }
    for( int j = 0 ; j < s2.size() ; j++ ){
      if( s2[j] == 'X' ) temp2[j] = i + '0';
    }
    for( int j = 0 ; j < s1.size() ; j++ ){
      if( s3[j] == 'X' ) temp3[j] = i + '0';
    }

    // cout << temp1 << " + " << temp2 << " = " << temp3 << endl;

    cnt = 1;
    S1 = S2 = S3 = 0;
    for( int j = s1.size() - 1 ; j >= 0 ; j-- ){
      S1 += (temp1[j] - '0')*cnt;
      cnt *= 10;
    }
    cnt = 1;
    for( int j = s2.size() - 1 ; j >= 0 ; j-- ){
      S2 += (temp2[j] - '0')*cnt;
      cnt *= 10;
    }
    cnt = 1;
    for( int j = s3.size() - 1 ; j >= 0 ; j-- ){
      S3 += (temp3[j] - '0')*cnt;
      cnt *= 10;
    }
    TF = compute();
    if(TF) return i;
  }
  return -1;
}

int main(void){

  while( cin >> s ){

    cnt = 0;
    s1 = s2 = s3 = "";

    devide();

    temp1 = s1;
    temp2 = s2;
    temp3 = s3;

    cnt = change();
    if( 0 <= cnt && cnt <= 9 ) cout << cnt << endl;
    else cout << "NA" << endl;

  }
  return 0;
}