#include<cstdio>
#include<vector>
#include<cstring>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

char *add(const char *aa,const char *bb){
	int m=strlen(aa),n=strlen(bb);
	int a[128]={},b[128]={};
	rep(i,m) a[i]=aa[m-i-1]-'0';
	rep(i,n) b[i]=bb[n-i-1]-'0';

	m=max(m,n);
	int c[128]={};
	rep(i,m){
		int tmp=c[i]+a[i]+b[i];
		c[i]=tmp%10;
		c[i+1]=tmp/10;
	}
	if(c[m]!=0) m++;

	static char cc[128];
	rep(i,m) cc[i]=c[m-i-1]+'0';
	cc[m]='\0';
	return cc;
}

int main(){
	for(char s[128];~scanf("%s",s);){
		char a[128],b[128],c[128];
		for(int i=0,p=0;;i++){
			if(s[i]=='+'){
				strncpy(a,s+p,i-p);
				a[i-p]='\0';
				p=i+1;
			}
			else if(s[i]=='='){
				strncpy(b,s+p,i-p);
				b[i-p]='\0';
				p=i+1;
			}
			else if(s[i]=='\0'){
				strncpy(c,s+p,i-p);
				c[i-p]='\0';
				break;
			}
		}

		vector<int> xa,xb,xc;
		for(int i=0;a[i];i++) if(a[i]=='X') xa.push_back(i);
		for(int i=0;b[i];i++) if(b[i]=='X') xb.push_back(i);
		for(int i=0;c[i];i++) if(c[i]=='X') xc.push_back(i);

		int x;
		for(x=0;x<10;x++){
			rep(i,xa.size()) a[xa[i]]=x+'0';
			rep(i,xb.size()) b[xb[i]]=x+'0';
			rep(i,xc.size()) c[xc[i]]=x+'0';
			if(strcmp(add(a,b),c)==0) break;
		}
		if(x<10) printf("%d\n",x);
		else     puts("NA");
	}

	return 0;
}