#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;

int main(){
  string str;
  while(cin >> str){
    string num[3] = {"","",""};
    int idx = 0;
    for(int i=0;i<str.size();i++){
      if(str[i] == '+' || str[i] == '=') idx++;
      else {
	num[idx] += str[i];
      }
    }
    int flg = false;
    for(char c='0';c<='9';c++){
      if(c == '0'){
	//if(num[0][0] == 'X' || num[1][0] == 'X' || num[2][0] == 'X') continue;
      }
      string tmp[3] = {"","",""};
      for(int i=0;i<3;i++){
	for(int j=0;j<num[i].size();j++){
	  if(num[i][j] == 'X') tmp[i] += c;
	  else tmp[i] += num[i][j];
	}
      }
      int a = atoi(tmp[0].c_str());
      int b = atoi(tmp[1].c_str());
      int ans = atoi(tmp[2].c_str());
      if(a + b == ans){
	cout << c << endl;
	flg = true;
	break;
      }
    }
    if(!flg) {
      cout << "NA" << endl;
    }
  }
}