#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){
  string o;
  while(cin>>o){
    rep(i,10){
      string s = o;
      int a,b;
      rep(j,s.size()){
	if(s[j] == 'X')s[j] = (char)(i+'0');
	if(s[j] == '+')a=j;
	if(s[j] == '=')b=j;
      }

      vector<string>ss(3);
      ss[0]=s.substr(0,a);
      ss[1]=s.substr(a+1,b-a-1);
      ss[2]=s.substr(b+1);            
      if(ss[0][0]=='0'&&ss[0].size()>1)continue;
      if(ss[1][0]=='0'&&ss[1].size()>1)continue;
      if(ss[2][0]=='0'&&ss[2].size()>1)continue;
      int k = 0;

      rep(j,3){
	int t = ss[j].size();
	k=max(k,t);
      }

      rep(j,3)while(k!=ss[j].size())ss[j]="0"+ss[j];
      for(int j = k-1 ; j >= 0 ; j --){
	ss[0][j]+=ss[1][j]-'0';
	if(ss[0][j]>'9'){ss[0][j]-=10;ss[0][j-1]++;}
      }

      if(ss[0]==ss[2]){cout<<i<<endl;break;}
      if(i==9)cout<<"NA"<<endl;
      //*/
    }
  }
}