#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
using namespace std;
const int LEN = 128;

char *XtoN(char *str,char c){
	char buf[LEN];
	strcpy(buf,str);
	for(int i=0; i<strlen(str); i++){
		if(i==0&&c=='0')continue;
		if(buf[i]=='X') buf[i]=c;
	}
	return buf;
}

int main(void){
	char str1[LEN],str2[LEN],sum[LEN],buf;
	char str1b[LEN],str2b[LEN],sumb[LEN];
	int x,y,z;

	scanf("%[^+]s",str1);
	scanf("%c%[^=]s",&buf,str2);
	scanf("%c%s",&buf,sum);

	char c;
	for(c='0'; c<='9'; c++){
		strcpy(str1b,XtoN(str1,c)); x = atoi(str1b);
		strcpy(str2b,XtoN(str2,c)); y = atoi(str2b);
		strcpy(sumb,XtoN(sum,c));   z = atoi(sumb);
		if(x+y==z)break;
	}

	if('0'<=c && c<='9')
		cout << c << endl;
	else
		cout << "NA" << endl;

	return 0;
}