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

vector<string> split(string s){
  vector<string> ret;
  string tmp;
  int i;
  for(i = 0 ; i < s.size() ; i++){
    if(s[i] == '+') break;
    tmp += s[i];
  }
  ret.push_back(tmp);
  tmp = "";
  i++;
  for( ; i < s.size() ; i++){
    if(s[i] == '=') break;
    tmp += s[i];
  }
  ret.push_back(tmp);
  tmp = "";
  i++;
  for( ; i <= s.size() ; i++){
    if(i == s.size()) break;
    tmp += s[i];
  }
  ret.push_back(tmp);
  return ret;
}

string convert(string s, char n){
  for(int i = 0 ; i < s.size() ; i++){
    if(s[i] == 'X') s[i] = n;
  }
  return s;
}

void solve(vector<string> cal){
  for(char N = '0' ; N <= '9' ; N++){
    string t[3];
    for(int i = 0 ; i < 3 ; i++){
      t[i] = convert(cal[i], N);
    }
    
    if(atoi(t[0].c_str()) + atoi(t[1].c_str()) == atoi(t[2].c_str())){
      cout << N << endl;
      return;
    }
  }
  cout << "NA" << endl;
  return;
}
  
int main(){
  string s;
  while(getline(cin, s)){
    vector<string> cal = split(s);
    solve(cal);
  }
  return 0;
}






      
    
    
      