#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  string s;
  while(cin >> s) {
    bool flag = true;
    REP(i, 10) {
      int a, b, c;
      string t = "";
      REP(j, s.size()) {
        if(s[j] == '+') {
          a = stoi(t);
          t = "";
        } else if(s[j] == '=') {
          b = stoi(t);
          t = "";
        } else if(s[j] == 'X') {
          t += '0' + i;
        } else {
          t += s[j];
        }
      }
      c = stoi(t);
      //cout << a << " " << b << " " << c << endl;
      if(a + b == c) {
        cout << i << endl;
        flag = false;
      }
    }
    if(flag) cout << "NA" << endl;
  }

  return 0;
}