#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;
    string a = s.substr(0, s.find("+")),
           b = s.substr(s.find("+")+1, s.find("=")-s.find("+")-1),
           c = s.substr(s.find("=")+1);
    //cout << a << " " << b << " " << c << endl;
    for(char i = '0'; i<='9'; ++i) {
      string aa = a, bb = b, cc = c;
      REP(j, a.size()) if(a[j] == 'X') aa[j] = i;
      REP(j, b.size()) if(b[j] == 'X') bb[j] = i;
      REP(j, c.size()) if(c[j] == 'X') cc[j] = i;
      int d = stoi(aa), e = stoi(bb), f = stoi(cc);
      //cout << d << " " << e << " " << f << endl;
      if(d + e == f) {
        cout << i << endl;
        flag = false;
        break;
      }
    }
    if(flag) cout << "NA" << endl;
  }

  return 0;
}