#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;
  while(cin>>str){
    string s1,s2,s3;
    for(int i=0;i<str.size();i++){
      if(str[i]=='+')
	s1=str.substr(0,i);
      if(str[i]=='=')
	s2=str.substr(s1.size()+1,i-s1.size()-1);
    }
    s3=str.substr(s1.size()+s2.size()+2,str.size()-s1.size()-s2.size()-2);
    //cout<<s1<<" "<<s2<<" "<<s3<<endl;
    int i;
    for(i=0;i<=9;i++){
      string S1=s1,S2=s2,S3=s3;
      if(S1[0]=='X'||S2[0]=='X'||S3[0]=='X')
	if(i==0)
	  continue;
      for(int j=0;j<S1.size();j++){
	if(S1[j]=='X')
	  S1[j]=i+'0';
      }
      for(int j=0;j<S2.size();j++){
	if(S2[j]=='X')
	  S2[j]=i+'0';
      }
      for(int j=0;j<S3.size();j++){
	if(S3[j]=='X')
	  S3[j]=i+'0';
      }
      if(S1.size()<S2.size()){
	int j=0;
	string s="";
	while(S1.size()+j!=S2.size()){
	  j++;
	  s+='0';
	}
	S1=s+S1;
      }
      if(S1.size()<S2.size()){
	int j=0;
	string s="";
	while(S1.size()+j!=S2.size()){
	  j++;
	  s+='0';
	}
	S1=s+S1;
      }
      if(S1.size()>S2.size()){
	int j=0;
	string s="";
	while(S1.size()!=S2.size()+j){
	  j++;
	  s+='0';
	}
	S2=s+S2;
      }
      int flag=0;
      int ansflag=1;
      int j;
      if(S3.size()==S1.size()){
	for(j=S1.size()-1;j>=0;j--){
	  int num=S1[j]-'0'+S2[j]-'0'+flag;
	  //cout<<num<<endl;
	  flag=num/10;
	  if(num%10!=S3[j]-'0'){
	    ansflag=0;
	  break;
	  }
	}
      }else{
	for(j=S1.size()-1;j>=0;j--){
	  int num=S1[j]-'0'+S2[j]-'0'+flag;
	  //cout<<num<<endl;
	  flag=num/10;
	  if(num%10!=S3[j+1]-'0'){
	    ansflag=0;
	    break;
	  }
	}
	if(flag==0||flag!=S3[0]-'0')
	  ansflag=0;
      }
      if(ansflag){
	break;
      }
    }
    if(i==10)
      cout<<"NA"<<endl;
    else
      cout<<i<<endl;
  }
  return 0;
}