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

int main() {
  int to1,to2,x,sizea,sizeb,sizec,order,left,right,answer,xistop=0;
  string str,a,b,c,tempo;
  while(cin >> str) {
    xistop=0;
    left = 0;
    right = 0;
    to1 = str.find("+");
    a = str.substr(0,to1);
    to2 = str.find("=");
    b = str.substr(to1+1,to2-to1-1);
    c = str.substr(to2+1);
    // cout << a << " " << b << " " << c << endl;

    sizea = a.size();
    for(int i=0;i<sizea;i++) {
      tempo = a.substr(sizea-i-1,1);
      if(tempo != "X") {
	x = atoi(tempo.c_str());
	for(int j=0;j<i;j++) {
	  x *= 10;
	}
	left += x; // ok
      }
      else {
	if(i==sizea-1) {
	  xistop = 1;
	}
	order = 1;
	for(int j=0;j<i;j++) {
	  order *= 10;
	}
	right -= order;
      }
    }

    sizeb = b.size();
    for(int i=0;i<sizeb;i++) {
      tempo = b.substr(sizeb-i-1,1);
      if(tempo != "X") {
	x = atoi(tempo.c_str());
	for(int j=0;j<i;j++) {
	  x *= 10;
	}
	left += x; // ok
      }
      else {
	if(i==sizeb-1) {
	  xistop = 1;
	}
	order = 1;
	for(int j=0;j<i;j++) {
	  order *= 10;
	}
	right -= order;
      }
    }

    sizec = c.size();
    for(int i=0;i<sizec;i++) {
      tempo = c.substr(sizec-i-1,1);
      if(tempo != "X") {
	x = atoi(tempo.c_str());
	for(int j=0;j<i;j++) {
	  x *= 10;
	}
	left -= x; // ok
      }
      else {
	if(i==sizec-1) {
	  xistop = 1;
	}
	order = 1;
	for(int j=0;j<i;j++) {
	  order *= 10;
	}
	right += order;
      }
    }
    answer = left / right;
  
    if(left % right == 0)
      if((xistop != 1) || (answer != 0)){
      cout << answer << endl;
      }
      else {
	cout << "NA" << endl;
      }
    else
      cout << "NA" << endl;
  }
}