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

string calc(string s1, string s2){
  string res;
  int n = max(s1.size(), s2.size());
  while(s1.size() < n) s1 = '0' + s1;
  while(s2.size() < n) s2 = '0' + s2;
  int c = 0;
  for(int i = n-1 ; i >= 0 ; i--){
    char ch = ((s1[i]-'0')+(s2[i]-'0')+c)%10 + '0';
    c = ((s1[i]-'0')+(s2[i]-'0')+c)/10;
    res += ch;
  }
  if(c) res += c+'0';
  reverse(res.begin(), res.end());
  while(res.size() > 1 && res[0] == '0') res.erase(res.begin());
  return res;
}

int main(){    
  string op;
  while(cin >> op){  
    op += '=';
    bool flag = false;
    for(int ii = 0 ; ii <= 9 ; ii++){
      string left1, left2, right;
      int i;
      for(i = 0 ; i < op.size() ; i++){
	if(op[i] == '+' || op[i] == '=') break;
	if(op[i] == 'X') left1 += ii+'0';
	else left1 += op[i];
      }
      i++;
      for( ; i < op.size() ; i++){
	if(op[i] == '+' || op[i] == '=') break;
	if(op[i] == 'X') left2 += ii+'0';
	else left2 += op[i];
      }
      i++;
      for( ; i < op.size() ; i++){
	if(op[i] == '=') break;
	if(op[i] == 'X') right += ii+'0';
	else right += op[i];
      }    
      if(calc(left1, left2) == right){
	cout << ii << endl;
	flag = true;
	break;
      }
    }
    if(!flag) cout << "NA" << endl;
  }
  return 0;
}
    