#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

string add(string a, string b) {
  string c = "";
  if (a.size() < b.size()) {
    string tmp = a;
    a = b;
    b = tmp;
  }
  int i = a.size()-1, j = b.size()-1;
  int carry = 0;
  while (j >= 0) {
    char tmp = a[i] + b[j] -'0' + carry;
    if (tmp > '9') {
      carry = 1;
      c = (char)(tmp - 10) + c;
    } else {
      carry = 0;
      c = tmp + c;
    }
    i--;
    j--;
  }
  if (carry == 1 && i < 0)
    c = '1' + c;
  else if (carry == 1)
    c = (char)(a[i--] + 1) + c;
  while (i >= 0)
    c = (char)a[i--] + c;
  return c;
}

int main(int argc, char *argv[]) {
  string s;
  vector<int> xp;
  vector<string> result;
  while (getline(cin, s)) {
    bool hoge = true;
    for (int i = 0; i < s.size(); i++)
      if (s[i] == 'X')
        xp.push_back(i);
      else if (s[i] == '+' || s[i] == '=')
        s[i] = ' ';

    for (int i = 0; i < 10; i++) {
      bool piyo = false;
      for (int j = 0; j < xp.size(); j++)
        if (i == 0 && (xp[j] == 0 || s[xp[j]-1] == ' ')) {
          piyo = true;
          break;
        } else {
          s[xp[j]] = '0'+i;
        }
      if (piyo)
        continue;
      stringstream ss(s);
      string a, b, c;
      ss >> a >> b >> c;
      string sum = add(a,b);
      /*                                                                                                                                                                                                                                                                                                                                            
      cout << a << '+' << b << '=' << c << endl;                                                                                                                                                                                                                                                                                                    
      cout << sum << endl;                                                                                                                                                                                                                                                                                                                          
      */
      if (sum == c) {
        string tmp = "0";
        tmp[0] += i;
        result.push_back(tmp);
        hoge = false;
      }
    }
    if (hoge)
      result.push_back("NA");
    xp.clear();
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}