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

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);
      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(atoi(na.c_str()) + atoi(nb.c_str()) == atoi(nc.c_str())) {
          cout << x << endl;
          throw 0;
        }
      }
      cout << "NA" << endl;
    } catch(...) {}
  }
  return 0;
}