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

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  vector<int> xp;

  while (getline(cin, s)) {
    bool hoge = false;
    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);
      int a, b, c;
      ss >> a >> b >> c;
      if (a + b == c) {
        cout << i << endl;
        hoge = true;
      }
    }
    if (hoge)
      continue;
    cout << "NA" << endl;
    xp.clear();
  }
  return 0;
}