#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

string add(string a, string b) {
	reverse(ALL(a));
	reverse(ALL(b));
	int al = a.length();
	int bl = b.length();
	string res;
	int tmp, carry = 0;
	REP(i, max(al, bl)) {
		if(i < al && i < bl) {
			tmp = (a[i]-'0')+(b[i]-'0');
		} else if(i < al) {
			tmp = (a[i]-'0');
		} else if(i < bl) {
			tmp = (b[i]-'0');
		}
		tmp += carry;
		res.push_back(tmp%10+'0');
		carry = tmp/10;
	}
	if(carry) {
		res.push_back('1');
	}

	reverse(ALL(res));
	return res;
}

int main() {
	string s;
	while(cin >> s) {
		string a, b, c;
		int ppos = s.find_first_of('+');
		int epos = s.find_first_of('=');
		a = s.substr(0, ppos);
		b = s.substr(ppos+1, epos-a.length()-1);
		c = s.substr(epos+1);

		int ans = -1;
		REP(i, 10) {
			string na = a, nb = b, nc = c;
			REP(j, na.size()) {
				if(na[j] == 'X') {
					na[j] = i+'0';
				}
			}
			REP(j, nb.size()) {
				if(nb[j] == 'X') {
					nb[j] = i+'0';
				}
			}
			REP(j, nc.size()) {
				if(nc[j] == 'X') {
					nc[j] = i+'0';
				}
			}

			if(add(na, nb) == nc) {
				if(na[0] != '0' && nb[0] != '0') {
					ans = i;
					break;
				}
			}
		}

		if(ans == -1) {
			cout << "NA" << endl;
		} else {
			cout << ans << endl;
		}
	}

	return 0;
}