#include <iostream>
#include <sstream>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))

string in;

void solve() {
  const int sz = in.size();
  rep (i,10) {
    string cp = in;
    rep (j,sz) if (cp[j] == 'X') {
      cp[j] = '0' + i;
    }

    istringstream is(cp);
    int lhs_l, lhs_r, rhs;
    char c;
    is >> lhs_l >> c >> lhs_r >> c >> rhs;
    if (lhs_l + lhs_r == rhs) {
      cout << i << endl; return;
    }
  }
  cout << "NA" << endl; return;
}

int main() {
  while (cin >> in) {
    solve();
  }
  return 0;
}