#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

typedef vector<int> vi;

int x;

vi pls(string s1, string s2) {
  vi ret(201);

  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  
  for(int i=0; i<200; i++) {
	int n1=0, n2=0;
	if(i<s1.size()) n1 = s1[i]=='X' ? x : s1[i]-'0';
	if(i<s2.size()) n2 = s2[i]=='X' ? x : s2[i]-'0';
	ret[i] += n1+n2;
	if(ret[i]>9) {
	  ret[i+1]++;
	  ret[i]-=10;
	}
  }
  return ret;
}

vi str2vi(string s) {
  vi ret(201);
  
  reverse(s.begin(), s.end());
  
  for(int i=0; i<201; i++) {
	if(i<s.size()) ret[i] = s[i]=='X' ? x : s[i]-'0';
  }
  
  return ret;
}

int main() {
  string str;
  string s1, s2, rhs;
  while(cin >> str) {
	int ppos = str.find("+");
	int epos = str.find("=");
	rhs = str.substr(epos+1);
	s1 = str.substr(0, ppos);
	s2 = str.substr(ppos+1, epos-ppos-1);
	
	//cout << s1 << " " << s2 << " " << rhs << endl;
	
	for(x=0; x<10; x++) {
	  if(pls(s1, s2) == str2vi(rhs)) {
		cout << x;
		break;
	  }
	}
	if(x == 10) cout << "NA";
	cout << endl;
  }
  
  return 0;
}