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

string leng(int n,string s){
  while(n != (int)s.size()) s = '0' + s;
  return s;
}

string add(string a,string b){
  a = leng(200,a);
  b = leng(200,b);
  for(int i = (int)a.size()-1; i > 0; i--){
    a[i] += b[i]-'0';
    a[i-1] += (a[i]-'0')/10;
    a[i] = (a[i]-'0')%10 +'0';
  }
  return a;
}

int main(void){
  string str;
  while(cin >> str){

    bool f = true;
    for(int k = 0; k < 10; k++){
      int l = 0,p = 0;
      string a[3];
      string s = str + 'A';
      for(int i = 0; i < (int)s.size(); i++){
	if(s[i] == 'X') s[i] = k + '0';
	else if('0' > s[i] || s[i] > '9'){
	  a[p] = s.substr(l,i-l);
	  p++;
	  l = i+1;
	}
      }
      //cout << "a = " << add(a[0],a[1]) << endl;
      //cout << "b = " << leng(200,a[2]) << endl;
      if(add(a[0],a[1]) == leng(200,a[2])){
	f = false;
	cout << k << endl;
	break;
      }
    }
    if(f) cout << "NA" << endl;
  }
}