#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  string s;
  while(cin >> s) {
    int aa = s.find('+');
    int bb = s.find('=');
    string a[3];
    a[0]= s.substr(0,aa);
    a[1] = s.substr(aa+1,bb-aa-1);
    a[2] = s.substr(bb+1);
    

    int f = 0;
    REP(i,10) {
      string aa[3];
      REP(k,3)
        aa[k] = a[k];
      REP(k,3) 
        REP(j,a[k].length())
        if (a[k][j] == 'X')
          aa[k][j] = '0'+i;
      //REP(k,3)
        //    cout << aa[k] << endl;
      if (atoi(aa[0].c_str())+atoi(aa[1].c_str()) == atoi(aa[2].c_str())) {
        cout << i << endl;
        f = 1;
        break;
      }
    }
    if (!f)
      cout << "NA" << endl;
  }
}