#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	string n;
	while (cin >> n){
		int pidx = -1, eidx = -1;
		FOR(i, n.size()){
			if (n[i] == '+') pidx = i;
			if (n[i] == '=') eidx = i;
		}

		string a = n.substr(0, pidx);
		string b = n.substr(pidx + 1, eidx - (pidx + 1));
		string c = n.substr(eidx + 1, n.size() - (eidx + 1));

		int ans = -1;
		FOR(i, 10){
			string aa = a, bb = b, cc = c;

			FOR(j, aa.size()) if (aa[j] == 'X') aa[j] = i + '0';
			FOR(j, bb.size()) if (bb[j] == 'X') bb[j] = i + '0';
			FOR(j, cc.size()) if (cc[j] == 'X') cc[j] = i + '0';

			int aaa = 0, bbb = 0, ccc = 0;
			FOR(j, aa.size()){ aaa *= 10; aaa += aa[j] - '0'; }
			FOR(j, bb.size()){ bbb *= 10; bbb += bb[j] - '0'; }
			FOR(j, cc.size()){ ccc *= 10; ccc += cc[j] - '0'; }

			if (aaa + bbb == ccc){
				ans = i;
				break;
			}
		}

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

		if (cin.eof()) break;
 	}

	return 0;
}