#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int getnum(string &s, int l, int x, int i) {
  char c;
  if (i>=l) return 0;
  c = s.at(l-i-1);
  if (c=='X') {
    return x;
  } else {
    return c-'0';
  }
}

int main() {
  int a, b, c, i, m, s, t, u, v, w, x;
  bool nonzero;
  string eq;
  string l1, l2, r;
  while (getline(cin, eq)) {
    a = eq.find("+");
    b = eq.find("=");
    c = eq.length();
    l1 = eq.substr(0, a);
    l2 = eq.substr(a+1, b-a-1);
    r = eq.substr(b+1, c-b);
    a = l1.length();
    b = l2.length();
    c = r.length();
    m = max(max(a,b),c);
    if (l1[0]=='X'||l2[0]=='X'||r[0]=='X') {
      nonzero = true;
    } else {
      nonzero = false;
    }
    for (x=0; x<10; x++) {
      v = 0;
      for (i=0; i<=m; i++) {
        s = getnum(l1, a, x, i);
        t = getnum(l2, b, x, i);
        u = getnum(r, c, x, i);
        w = s + t + v;
        if (w >= 10) {
          w -= 10;
          v = 1;
        } else {
          v = 0;
        }
        if (w != u) break;
      }
      if (i>m) break;
    }
    if (x==10 || (!x && nonzero)) {
      cout << "NA" << endl;
    } else {
      cout << x << endl;
    }
  }
  return 0;
}