#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){
			//3桁以上の数列で先頭にXがある場合は0を飛ばす.
			if (a.size() >= 3 && i == 0 && a[0] == 'X') continue;
			if (b.size() >= 3 && i == 0 && b[0] == 'X') continue;
			if (c.size() >= 3 && i == 0 && c[0] == 'X') continue;

			string aa = a, bb = b, cc = c;

			//Xを置き換える.
			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 ca = cc.size() - aa.size();
			int cb = cc.size() - bb.size();
			FOR(i, ca) aa.insert(0, "0");
			FOR(i, cb) bb.insert(0, "0");

			//筆算.
			int m = cc.size();
			int up = 0;
			string res(m, ' ');
			FOR(j, m){
				int s = aa[(m - 1) - j] - '0';
				int t = bb[(m - 1) - j] - '0';

				res[(m - 1) - j] = ( (s + t + up) % 10 ) + '0';
				up = (s + t + up) / 10;
				
			}

			//計算結果と結果の数列を比較して一緒なら終了.
			if (res == cc){
				ans = i;
				break;
			}
		}

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

		if (cin.eof()) break;
 	}

	return 0;
}