//20
#include<iostream>
#include<sstream>
#include<string>

using namespace std;

string itos(int i){
  stringstream ss;
  ss<<i;
  return ss.str();
}

int main(){
  for(string se;cin>>se;){
    int i;
    int ac=0,ans;
    for(i=0;i<=9;i++){
      string s=se;
      for(int j=0;j<s.size();j++){
	if(s[j]=='X'){
	  s[j]='0'+i;
	}
      }
      stringstream ss(s);
      int a,b,c;
      ((ss>>a).ignore()>>b).ignore()>>c;
      if(itos(a)+'+'+itos(b)+'='+itos(a+b)==s){
	ans=i;
	ac++;
	/*
	cout<<i<<endl;
	break;
	*/
      }
    }
    /*
    if(!(i<=9)){
      cout<<"NA"<<endl;
    }
    */
    if(ac==1){
      cout<<ans<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
  return 0;
}