#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
  char s[128];
  while (scanf("%s", s) == 1) {
    char eq[128];
    bool f(false);
    for (char x = '0'; x <= '9'; x++) {
      int a, b, c;
      fill(eq, eq+128, 0);
      for (int i = 0; s[i]; i++)
        if (s[i] == 'X') 
          if (x == '0' &&
              (!i || i >= 0 && (s[i-1] == '+' || s[i-1] == '=')) &&
              '0' <= s[i+1] && s[i+1] <= '9')
            goto next;
          else
            eq[i] = x;
        else
          eq[i] = s[i];
      sscanf(eq, "%d+%d=%d", &a, &b, &c);
      if (a + b == c) {
        printf("%c\n", x);
        f = true;
        break;
      }
next:;
    }
    if (!f)
      puts("NA");
  }
  return 0;
}