#include<iostream>
#include<cstdlib>
#include<sstream>
#include<algorithm>
#include<cassert>
using namespace std;

string Replace(string s,char c){
  string res;
  res.clear();
  for(int i=0;i<s.length();i++){
    if(s[i] == 'X')res+=c;
    else res+=s[i];
  }
  return res;
}

string its(int num){
  stringstream ss;
  ss << num;
  return ss.str();
}

string calc(string a,string b){
  string s,val;
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  int A,B,C,D;//D<-繰り上がり分
  D=0;
  for(int i=0;i<max(a.size(),b.size());i++){
    if(i>=a.size()){
      B = b[i]-'0';
      C = B+D;
      val = its(C);
      assert(C<=20);
      if(C>=10)D=1;
      else D=0;
      s+=val[val.size()-1];
    }
    else if(i>=b.size()){
      A = a[i]-'0';
      C = A+D;
      val = its(C);
      assert(C<=20);
      if(C>=10)D=1;
      else D=0;
      s+=val[val.size()-1];
    }
    else{
      A = a[i]-'0';
      B = b[i]-'0';
      C = A+B+D;
      val = its(C);
      assert(C<=20);
      if(C>=10)D=1;
      else D=0;
      s+=val[val.size()-1];
    }
  }
  if(D == 1){
    s+='1';
  }
  reverse(s.begin(),s.end());
  return s;
}

bool isEqual(string a,string b){
  if(a.size() != b.size())return false;
  bool same = true;
  for(int i=0;i<a.size();i++){
    if(a[i] != b[i]){
      same = false;
      break;
    }
  }
  return same;
}

int main(){
  string s;
  int st,A,B,C,index;
  string Smen[3],As,Bs,Cs;
  string lans,rans;

  while(cin >> s){
    st = index = 0;

    for(int i=0;i<=s.length();i++){
      if(s[i] == '+' || s[i] == '=' || i == s.length()){
	Smen[index++]=s.substr(st,i-st);
	st = i+1;
      }
    }
    char c='0';
    bool found = false;
    for(int i=0;i<=9;i++){
      c=(char)('0'+i);
      
      if(i == 0 && ((Smen[0][0] == 'X' && Smen[0].size() > 1) || (Smen[1][0] == 'X' && Smen[1].size() > 1)|| (Smen[2][0] == 'X' && Smen[2].size() > 1)))continue;
      As = Replace(Smen[0],c);
      Bs = Replace(Smen[1],c);
      Cs = Replace(Smen[2],c);
      lans = calc(As,Bs);
      rans = Cs;
      if(isEqual(lans,rans)){
	cout << i << endl;
	found = true;
	break;
      }
    }  
    if(!found)cout << "NA" << endl;

  }
  return 0;
}