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

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

string s;

int i2c(int i){return '0'+i;}

void solve() {
  string lhs, rhs, res;
  int plus = s.find('+'), eq = s.find('=');
  lhs = s.substr(0, plus);
  rhs = s.substr(plus+1, eq-plus-1);
  res = s.substr(eq+1);
  
  bool flag = ((lhs[0] == 'X' && lhs.size() > 1) ||
               (rhs[0] == 'X' && rhs.size() > 1) ||
               (res[0] == 'X' && res.size() > 1)) ? true : false;
  rep(i,10) {
    if (i == 0 && flag) continue;
    
    string clh = lhs, crh = rhs, crs = res;
    rep(j,clh.size()) if (clh[j] == 'X') clh[j] = i2c(i);
    rep(j,crh.size()) if (crh[j] == 'X') crh[j] = i2c(i);
    rep(j,crs.size()) if (crs[j] == 'X') crs[j] = i2c(i);
    
    //cout<<clh<<"|"<<crh<<"|"<<crs<<endl;
    if (atoi(crs.c_str()) == atoi(clh.c_str()) + atoi(crh.c_str())) {
      cout<<i<<endl;
      return;
    }
  }
  cout<<"NA"<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>s) {
    solve();
  }
  return 0;
}