#include<stdio.h>

void GG(int n1[127],int n2[127],int n3[127],int c1,int c2,int c3,int z1,int z2,int z3);
int GGG(int n1[127],int c1,int z1,int x)
{
	int t=1;
for(int i=c1-1;i>=0;i--)
{if(n1[i]==100)n1[i]=x;
	
	z1+=n1[i]*t;t*=10;}
return z1;
}



int main(){





	

int n1[127]={},n2[127]={},n3[127]={};
int nn1[127]={},nn2[127]={},nn3[127]={};

char ch;

while(scanf("%c",&ch)!=EOF){

int x=100,y,z,c1=0,c2=0,c3=0;
int z1=0,z2=0,z3=0;


while(1){
	
if(ch!='X')n1[c1]=ch-'0';
else n1[c1]=x;
nn1[c1]=n1[c1];
c1++;
scanf("%c",&ch);
if(ch=='+')break;
}



while(1){
	scanf("%c",&ch);
	if(ch=='=')break;
	
	if(ch!='X')n2[c2]=ch-'0';
else n2[c2]=x;
nn2[c2]=n2[c2];
c2++;
}




while(1){
	scanf("%c",&ch);
	if(ch=='\n')break;
if(ch!='X')n3[c3]=ch-'0';
else n3[c3]=x;
nn3[c3]=n3[c3];
c3++;

}



bool f=true;
x=1;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("1\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}


x=2;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("2\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}


x=3;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("3\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}


x=4;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("4\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}



x=5;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("5\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}




x=6;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("6\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}


x=7;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("7\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}



x=8;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("8\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}



x=9;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3){
	printf("9\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}


x=0;
z1=GGG(n1,c1,z1,x);z2=GGG(n2,c2,z2,x);z3=GGG(n3,c3,z3,x);
if(z1+z2==z3&&((n1[0]!=0&&c1>=2)||c1==1)&&((n2[0]!=0&&c2>=2)||c2==1)){
	printf("0\n");f=false;}
z1=0;z2=0;z3=0;
for(int i=0;i<126;i++)
{n1[i]=nn1[i];n2[i]=nn2[i];n3[i]=nn3[i];}


/*
x=1;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("1\n");f=false;printf("%d+%d=%d",z1,z2,z3);}
x=2;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("2\n");f=false;}
x=3;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("3\n");f=false;}
x=4;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("4\n");f=false;}
x=5;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("5\n");f=false;}
x=6;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("6\n");f=false;}
x=7;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("7\n");f=false;}
x=8;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("8\n");f=false;}
x=9;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("9\n");f=false;}
x=0;GG(n1,n2,n3,c1,c2,c3,z1,z2,z3);if((z1+z2)==z3){printf("0\n");f=false;}
*/
if(f!=false)printf("NA\n");
}

return 0;
}
void GG(int n1[127],int n2[127],int n3[127],int c1,int c2,int c3,int z1,int z2,int z3)
{
int t=1;
for(int i=c1-1;i>=0;i--)
{z1+=n1[i]*t;t*=10;}
t=1;
for(int i=c2-1;i>=0;i--)
{z2+=n2[i]*t;t*=10;}
t=1;
for(int i=c3-1;i>=0;i--)
{z3+=n3[i]*t;t*=10;}
printf("%d",z1);

}

Measured memory_bytes: 948