#include <iostream>

using namespace std;

int to_int (const string& str, int x){
  int a = 0;
  for (int i = 0; i < str.size(); i++) {
    a *= 10;
    if (str[i] == 'X')
      a += x;
    else
      a += str[i] - '0';
  }
  return a;
}

int main () {
  string shiki, sa, sb, sc;
  size_t pos_plus, pos_equal;
  int a, b, c;
  bool success;

  while (cin >> shiki) {
    pos_plus = shiki.find('+');
    pos_equal = shiki.find('=');
    sa = shiki.substr(0, pos_plus); 
    sb = shiki.substr(pos_plus + 1, pos_equal - pos_plus - 1);
    sc = shiki.substr(pos_equal + 1);
    a = b = c = 0;
    success = false;

    for (int i = 0; i < 10; i++) {
      if (i == 0 && (sa[0] == 'X' || sb[0] == 'X' || sc[0] == 'X'))
        continue;
      a = to_int(sa, i);
      b = to_int(sb, i);
      c = to_int(sc, i);
      if (a + b == c) {
        cout << i << endl;
        success = true;
        break;
      }
    }
    if(!success)
      cout << "NA" << endl;
  }
}