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

int ctoi(char c) { return c - '0'; }
char itoc(int i) { return '0' + i; }

string putX(string str, int x) {
  for(int i = 0; i < str.length(); ++i) {
    if(str[i] == 'X') str[i] = itoc(x);
  }
  return str;
}

string put0(string str, unsigned int length) {
  while(str.length() < length) {
    str.insert(0, "0");
  }
  return str;
}

string calc(string s1, string s2) {
  if(s1.length() < s2.length())      s1 = put0(s1, s2.length());
  else if(s1.length() > s2.length()) s2 = put0(s2, s1.length());

  int buf = 0;
  string res = "";
  for(int i = s1.length()-1; i >= 0; --i) {
    int a = ctoi(s1[i]) + ctoi(s2[i]) + buf;
    buf = a / 10;
    res.insert(0, string(1, itoc(a%10)));
  }
  if(buf != 0) res.insert(0, string(1, itoc(buf)));
  return res;
}

void solve(string &str) {
  string s1, s2, s3;
  int posP, posE;
  posP = str.find("+");
  posE = str.find("=");
  s1 = str.substr(0, posP);
  s2 = str.substr(posP+1, posE-(posP+1));
  s3 = str.substr(posE+1);
  for(int x = 0; x <= 9; ++x) {
    if( x == 0 &&
	(s1[0] == 'X' || s2[0] == 'X' || s3[0] == 'X') ) continue;
    if(calc(putX(s1, x), putX(s2, x)) == putX(s3, x)) {
      cout << x << endl;
      return;
    }
  }
  cout << "NA" << endl;
}

main() {
  string str;
  while(getline(cin, str)) solve(str);
}