#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
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);}

ll ltos(string num,int x){
  ll res = 0;
  rep(i,num.size()){
    if(num[i] == 'X')res = res * 10 + x;
    else res = res * 10 + num[i] - '0';
  }
  return res;
}

int main(void){
  string in;
  while(cin>>in,!cin.eof()){
  int i;
  string f,s,a;
  for(i = 0 ; in[i] != '+' ; i ++)
    f += in[i];  
  //  cout<<f<<endl;
  for(i++;in[i] != '=' ; i ++)
    s += in[i];
  //  cout<<s<<endl;
  for(i++;in[i] != '\0' ; i ++)
    a += in[i];
  //  cout<<a<<endl;
  bool used = false;
  rep(i,10){
    if(ltos(a,i)==ltos(f,i)+ltos(s,i)){
      used = true;
      cout<<i<<endl;
    }
  }
  if(!used)cout<<"NA"<<endl;
  }
}