#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  char s[256];
  char cp[256];
  while(scanf("%s",s)!=EOF){
    //cout<<s<<endl;
    int aa,bb,cc;
    int i=1;
    for(aa = 1 ; s[i] != '+' ; i ++, aa*=10);i+=2;
    for(bb = 1 ; s[i] != '=' ; i ++, bb*=10);i+=2;
    for(cc = 1 ; s[i] != '\0' ; i ++, cc*=10);

    //cout<<aa<<" "<<bb<<" "<<cc<<endl;
    bool f = true;
    rep(j,10){
      for(int i = 0 ; s[i] != '\0' ; i ++){
	if(s[i] == 'X')cp[i] = j + '0';
	else cp[i] = s[i];
      }
      int a,b,c;
      sscanf(cp,"%d+%d=%d",&a,&b,&c);
      if(a < aa || b < bb || c < cc)continue;
      //printf("%d,%d,%d\n",a,b,c);
      if(a+b==c){
	cout<<j<<endl;
	f = false;
      }
    }
    if(f)cout<<"NA"<<endl;
  }
}