#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#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()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  string str;
  while(cin>>str){
    int posP, posE;
    posP = str.find('+');
    posE = str.find('=');

    string op1, op2, ans;
    op1 = str.substr(0, posP);
    op2 = str.substr(posP+1, posE - posP - 1);
    ans = str.substr(posE+1);
    //cout << op1 << " + " << op2 << " = " << ans << endl;

    bool canZero = true;
    if(op1[0] == 'X' || op1[0] == 'X' || ans[0] == 'X')
      canZero = false;

    int ret = -1;
    for(char c = (canZero ? '0' : '1'); c <= '9'; c++){
      string opt1=op1, opt2=op2, anst=ans;
      while(opt1.find('X') != -1) opt1[opt1.find('X')] = c;
      while(opt2.find('X') != -1) opt2[opt2.find('X')] = c;
      while(anst.find('X') != -1) anst[anst.find('X')] = c;
      int a,b,d;
      a = atoi(opt1.c_str());
      b = atoi(opt2.c_str());
      d = atoi(anst.c_str());

      if(a+b == d){
        ret = c - '0';
        break;
      }
    }
    if(ret == -1) cout << "NA" << endl;
    else cout << ret << endl;
  }
  return 0;
}