#include <iostream>
#include <string>
using namespace std;

int check(int,int);

int isNum(int c){
	if(48<=c && c<=57){
	 return c-48;
	}
	return -1;
}

int main(){
	string s;
	string a,b,c;
	int an,bn,cn;
	int A,B,C;
	int i,tmp;
	int X;
	
	int loop;
	
	for(loop=0;loop<3;loop++){
	 cin>>s;s+='e';
	 a="";b="";c="";an=0;bn=0;cn=0;
	 i=0;while(s[i]=='+'){
	  a+=s[i];an++;
	  i++;
	 }
	 i++;while(s[i]=='='){
	  b+=s[i];bn++;
	  i++;
	 }
	 i++;while(s[i]=='e'){
	  c+=s[i];cn++;
	  i++;
	 }
	 
	 A=0;B=0;C=0;
	 for(X=0;X<10;X++){
	  for(i=0;i<an;i++){
	   A*=10;
	   tmp=isNum(a[i]);
	   if(tmp==-1){A+=X;}else{A+=tmp;}
	  }
	  for(i=0;i<bn;i++){
	   B*=10;
	   tmp=isNum(b[i]);
	   if(tmp==-1){B+=X;}else{B+=tmp;}
	  }
	  for(i=0;i<cn;i++){
	   C*=10;
	   tmp=isNum(c[i]);
	   if(tmp==-1){C+=X;}else{C+=tmp;}
	  }
	  if(A+B==C){break;}
	 }
	 
	 if(X==10){cout<<"NA"<<endl;}else{cout<<X<<endl;}
	}
	
	return 0;
}