#include <stdio.h>

int atoi(char *str, int x){
  int res = 0;
  while (*str!='\0'){
    if (*str=='X'){
      res = res*10+x;
    } else {
      res = res*10+(*str-'0');
    }
    str++;
  }

  return res;
}

int main(void){
  char op1[128], op2[128], rh[128], *p;
  char in[128], *q;
  bool ok;

  while (scanf("%s", in)){
    p = op1;
    q = in;
    while (*q != '+'){
      *p++ = *q++;
    }
    q++;
    *p = '\0';
    p = op2;
    while (*q != '='){
      *p++ = *q++;
    }
    ok = false;
    for (int x=0; x<=9; x++){
      if (*op1=='X' || *op2=='X' || *rh=='X'){
	if (x==0) continue;
      }
      if (atoi(op1,x) + atoi(op2,x) == atoi(rh,x)){
	printf("%d\n", x);
	ok = true;
      }
    }
    if (!ok){
      printf("NA\n");
    }
  }

  return 0;
}