#include<iostream>
#include<cstdlib>

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;
}


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

  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[1][0] == 'X' || Smen[2][0] == 'X'))continue;
      As = Replace(Smen[0],c);
      Bs = Replace(Smen[1],c);
      Cs = Replace(Smen[2],c);
      A = (atoi)(As.c_str());
      B = (atoi)(Bs.c_str());
      C = (atoi)(Cs.c_str());
      if(A+B == C){
	found = true;
	cout << i << endl;
	break;
      }
    }  
    if(!found)cout << "NA" << endl;

  }
  return 0;
}