#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
  char s[128];
  while (scanf("%s", s) == 1) {
    bool f(false);
    for (char x('0'); x <= '9'; x++) {
      char a[128], b[128], c[128];
      char *i(a), *j(b), *k(c), *l(s);
      while (*l != '+')
        *i++ = *l++;
      *i = 0;
      *l++;
      while (*l != '=')
        *j++ = *l++;
      *j = 0;
      *l++;
      while (*l)
        *k++ = *l++;
      *k = 0;
      // printf("%s %s %s\n", a, b, c);
      if (x == '0' && (a[0] == 'X' || b[0] == 'X' || c[0] == 'X'))
        continue;
      for (i = a; *i; i++)
        if (*i == 'X')
          *i = x;
      for (i = b; *i; i++)
        if (*i == 'X')
          *i = x;
      for (i = c; *i; i++)
        if (*i == 'X')
          *i = x;
      // printf("%c %d %d %d\n", x, atoi(a), atoi(b), atoi(c));
      if (atoi(a) + atoi(b) == atoi(c)) {
        printf("%c\n", x);
        f = true;
        break;
      }
    }
    if (!f)
      puts("NA");
  }
  return 0;
}