#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  string op;
  while(cin >> op){
    op += '=';
    string left1, left2, right;
    
    int i;
    for(i = 0 ; i < op.size() ; i++){
      if(op[i] == '+' || op[i] == '=') break;
      left1 += op[i];
    }

    for(i++ ; i < op.size() ; i++){
      if(op[i] == '+' || op[i] == '=') break;
      left2 += op[i];
    }

    for(i++ ; i < op.size() ; i++){
      if(op[i] == '=') break;
      right += op[i];
    }
    bool flag = false;
    for(int i = 0 ; i <= 9 ; i++){
      string le1, le2, ri;
      for(int j = 0 ; j < left1.size() ; j++){
	if(left1[j] == 'X') le1 += i+'0';
	else le1 += left1[j];
      }
      for(int j = 0 ; j < left2.size() ; j++){
	if(left2[j] == 'X') le2 += i+'0';
	else le2 += left2[j];
      }
      for(int j = 0 ; j < right.size() ; j++){
	if(right[j] == 'X') ri += i+'0';
	else ri += right[j];
      }
      int l1 = atoi(le1.c_str());
      int l2 = atoi(le2.c_str());
      int r = atoi(ri.c_str());
      
      if(l1 + l2 == r){
	cout << i << endl;
	flag = true;
	break;
      }
    }
    if(!flag) cout << "NA" << endl;    
  }
  return 0;
}