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

#define X(a) (a=='X'?i:a-'0')

int resX(char *p[3]){
	int c[10]={0},i,x[10]={0};
	while(*p[2]){
		for(i=0;i<10;i++)
			if(X(*p[0]) + X(*p[1]) + c[i] == X(*p[2])) c[i] = 0;
			else if(X(*p[0]) + X(*p[1]) - 10 + c[i] == X(*p[2])) c[i] = 1;
			else x[i] = 1;
			p[0]++;p[1]++;p[2]++;
	}
	for(i=0;i<10;i++) if(!x[i]) return i;
	return -1;
}

void sstrrev(char *p){
	char c,*t = p + strlen(p)-1;
	while(p<t){
		c=*t;*t=*p;*p=c;
		p++;t--;
	}
}

int main(){
	long i,j,n;
	char buf[150], p;
	while(fgets(buf, 130, stdin)){
		char *p, *num[3], sp[3][150]={{0},{0},{0}},f=0;
		sstrrev(buf);
		num[2] = buf+1;
		*(p=strchr(buf, '='))=0;
		num[1]=++p;
		*(p=strchr(p, '+'))=0;
		num[0]=++p;
		if(num[0][strlen(num[0])-1]=='X' || num[1][strlen(num[1])-1]=='X' || num[2][strlen(num[2])-1]=='X') f=1;
//		cout << num[0] << "," << num[1] << "," << num[2] << endl;
		strcpy(sp[0], num[0]);
		for(i=strlen(sp[0]);i<126;i++) sp[0][i] = '0';
		strcpy(sp[1], num[1]);
		for(i=strlen(sp[1]);i<126;i++) sp[1][i] = '0';
		strcpy(sp[2], num[2]);
		num[0]=sp[0];num[1]=sp[1];num[2]=sp[2];
//		cout << num[0] << "," << num[1] << "," << num[2] << endl;
		int ret = resX(num);
		if((f && ret == 0) || ret < 0) cout << "NA" <<endl;
		else cout << ret <<endl;
	}
	return 0;
}