#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	string str;
	while (cin >> str) {

		vector<string> num(126*4);
		string s = "";
		bool flag;
		int idx = 0;

		rep(i, str.size()) {
			if (str[i] != '+' && str[i] != '=') {
				s += str[i];
			}
			else {
				num[idx++] = s;
				s = "";
			}
		}
		num[idx++] = s;

		vector<string> num_t = num;
		for (char i = '0'; i <= '9'; i++) {
			if ((num[0][0] == 'X' || num[1][0] == 'X' || num[2][0] == 'X') && i == '0')continue;
			rep(j, idx) {
				rep(k, num[j].size()) {
					if (num[j][k] == 'X')
						num[j][k] = i;
				}
			}
			ll num1 = stoll(num[0]);
			ll num2 = stoll(num[1]);
			ll res = stoll(num[2]);
			flag = false;
			if (num1 + num2 == res) {
				cout << i << endl;
				flag = true;
				break;
			}
			num = num_t;
		}
		if(!flag)
		cout << "NA" << endl;
	}
	return 0;
}