#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

bool cheak(string str){
  str+= '#';
  int spos = 0;
  int num[3];
  int p = 0;
  for(int i = 0 ; spos < str.size() ; i++ ){
    if(str[i+1] < '0' || '9' < str[i+1] ){
      num[p++] = atoi(str.substr(spos,i+1-spos).c_str());
      spos = i+2;
    }
  }
  return num[0] + num[1] == num[2];
}

int main(){
  string str;
  while(  cin >> str ){
    int f = 1;
    for(int i = 0 ; i < 10 ; i++ ){
      string tmp = str;
      for(int j = 0 ; j < tmp.size() ; j++ ){

	if(tmp[j] == 'X')tmp[j] = (i + '0');

      }
      if(cheak(tmp)){
	cout << i << endl;
	f = 0;
	break;
      }
    }
    if(f)cout << "NA" << endl; 
  }
}