#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, char *> P;
const int L = 200;

vector<string> split(const string &s, char delim) {
  vector<string> res;
  stringstream ss(s);
  string item;
  while (getline(ss, item, delim)) res.push_back(item);
  return res;
}

bool check(string a, string b, string c, int &num){
  REP(i, a.length()) if(a[i] == 'X') a[i] = num + '0';
  REP(i, b.length()) if(b[i] == 'X') b[i] = num + '0';
  REP(i, c.length()) if(c[i] == 'X') c[i] = num + '0';
  REVERSE(a); REVERSE(b);
  int pls = 0;
  stringstream ss;
  REP(i, max(a.length(), b.length())){
    if(i < a.length()) pls += (a[i] - '0');
    if(i < b.length()) pls += (b[i] - '0');
    ss << (pls % 10);
    pls /= 10;
  }
  if(pls != 0) ss << pls;
  string r = ss.str();
  REVERSE(r);
  return (r == c);
}

int main() {
  char _s[L];
  while(scanf("%s", _s) != EOF){
    string a, b, c, s = string(_s);
    vector<string> v = split(s, '=');
    a = v[0]; c = v[1];
    v = split(a, '+');
    a = v[0]; b = v[1];
    int ans = -1;
    REP(num, 10){
      if(num == 0 && ((a.length() > 1 && a[0] == 'X') || (b.length() > 1 && b[0] == 'X') || (c.length() > 1 && c[0] == 'X'))) continue;
      if(check(a, b, c, num)) ans = num;
    }
    if(ans == -1) cout <<"NA" <<endl;
    else cout <<ans <<endl;
  }
  return 0;
}