#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) {
    string a = s.substr(0, s.find("+")),
           b = s.substr(s.find("+")+1, s.find("=")-s.find("+")-1),
           c = s.substr(s.find("=")+1);

    reverse(ALL(a));
    reverse(ALL(b));
    reverse(ALL(c));
    string ans = "-1";
    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;

      if(i=='0' && aa.size()>=2 && aa[aa.size()-1]=='0') continue;
      if(i=='0' && bb.size()>=2 && bb[bb.size()-1]=='0') continue;
      if(i=='0' && cc.size()>=2 && cc[cc.size()-1]=='0') continue;

      string n = "";
      int ca=0, m = cc.size();
      REP(i, m) {
        int cu = ca;
        if(i<aa.size()) cu += (aa[i]-'0');
        if(i<bb.size()) cu += (bb[i]-'0');
        ca = cu/10;
        n += (cu%10+'0');
      }
      if(ca == 0 && n == cc) {
        ans = i;
      }
    }
    if(ans == "-1") cout << "NA" << endl;
    else cout << ans << endl;
  }

  return 0;
}