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

string add(string a, string b) {
  while(a.size() < b.size()) a.insert(0, "0");
  while(b.size() < a.size()) b.insert(0, "0");
  a.insert(0, "0");
  b.insert(0, "0");
  int n = a.size();
  string c(n, '0');
  for(int i = n-1, t = 0; i >= 0; --i) {
    int tmp = (a[i]-'0') + (b[i]-'0') + t;
    c[i] = tmp%10 + '0';
    t = tmp/10;
  }
  while(c[0] == '0') {
    c.erase(0, 1);
  }
  if(c.empty()) return "0";
  else return c;
}

int main() {
  string t;
  while(cin >> t) {
    string a, b, c;
    {
      int i = t.find('+');
      int j = t.find('=');
      a = t.substr(0, i);
      b = t.substr(i+1, j-(i+1));
      c = t.substr(j+1);
    }
    try {
      for(char x = '0'; x <= '9'; ++x) {
        string na = a;
        string nb = b;
        string nc = c;
        replace(na.begin(), na.end(), 'X', x);
        replace(nb.begin(), nb.end(), 'X', x);
        replace(nc.begin(), nc.end(), 'X', x);
        if(na[0] == '0' && na.size() >= 2) continue;
        if(nb[0] == '0' && nb.size() >= 2) continue;
        if(nc[0] == '0' && nc.size() >= 2) continue;
        if(add(na,nb) == nc) {
          cout << x << endl;
          throw 0;
        }
      }
      cout << "NA" << endl;
    } catch(...) {}
  }
  return 0;
}