
import std.stdio, std.ascii, std.conv, std.string;
import std.regex, std.math, std.bigint;

bool x_exists;

bool zero_filter(char[] str) {
  if (str.length == 1) return true;
  return str[0] != 'X';
}

BigInt conv(char[] str, int i) {
  BigInt x;
  int digit = 0;
  foreach(s; str) {
    BigInt n;
    if (s == 'X') {
      n = i;
      x_exists = true;
    }
    else if (isDigit(s)) n = s - '0';
    x = 10 * x + n;
    digit++;
  }
  return x;
}

void main() {
  string line;
  while ((line = readln) != null) {
    char[] expr = line.chomp.dup.to!(char[]);
    auto m = match(expr, r"^(.*?)\+(.*?)=(.*?)$").captures;
    int ans = -1;
    bool is_zero = true;
    for(int i = 1; i <= 3; i++) {
      is_zero &= zero_filter(m[i]);
    }
    for(int i = (is_zero ? 0 : 1); i <= 9; i++) {
      x_exists = false;
      if ((m[1].conv(i) + m[2].conv(i)) == m[3].conv(i)) {
        if (!x_exists) continue;
        ans = i;
        break;
      }
    }
    writeln((ans >= 0) ? ans.to!(string) : "NA");
  }
}