#include <iostream>
#include <string>

using namespace std;

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

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

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

int 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 = 0, p = s1.length()-1; i < s1.length(); ++i, --p) {
    int a = ctoi(s1[p]) + ctoi(s2[p]) + buf;
    buf = a / 10;
    a %= 10;
    res.insert(0, string(1, itoc(a)));
  }
  if(buf != 0) res.insert(0, string(1, itoc(buf)));

  return atoi(res.c_str());
}

void solve(string &str) {
  string s1, s2, s3;

  for(int i = 0, s = -1; ; ++i) {
    if(str[i] == '+') {
      s = i+1;
      s1 = str.substr(0, i);
    } else if(str[i] == '=') {
      s2 = str.substr(s, i-s);
      s3 = str.substr(i+1);
      break;
    }
  }

  for(int x = 0; x <= 9; ++x) {
    if(calc(putX(s1, x), putX(s2, x)) == atoi(putX(s3, x).c_str())) {
      cout << x << endl;
      return;
    }
  }
  cout << "NA" << endl;
}

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