#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;

int changei(string s){
	int res;
	stringstream ss;
	ss << s;
	ss >> res;
	return res;
}

bool check(string s1, string s2, string s3){
	int p = 0;
	int size = min(s2.size(), s1.size());
	for (int i = 0; i < size; i++){
		if ((s1[i] - '0' + s2[i] - '0' + p) % 10 != s3[i] - '0'){
			return false;
		}
		else{
			p = (s1[i] - '0' + s2[i] - '0' + p) / 10;
		}
	}
	if (s2.size()>s1.size()){
		for (int i = size; i < s3.size(); i++){
			if ((s2[i] - '0' + p) % 10 != s3[i] - '0'){
				return false;
			}
			else{
				p = (s2[i] - '0' + p) / 10;
			}
		}
	}
	else{
		for (int i = size; i < s3.size(); i++){
			if ((s1[i] - '0' + p) % 10 != s3[i] - '0'){
				return false;
			}
			else{
				p = (s1[i] - '0' + p) / 10;
			}
		}
	}
	return true;
}

int main(){
	while (cin >> s){
		bool f = 1;
		int wide1, wide2;
		REP(i, s.size()){
			if (s[i] == '+')wide1 = i;
			else if (s[i] == '=')wide2 = i - wide1 - 1;
		}
		REP(i, 10){
			string t1 = s.substr(0, wide1), t2 = s.substr(wide1 + 1, wide2),
				t3 = s.substr(wide1 + wide2 + 2, s.size() - wide1 - wide2);
			REP(j, t1.size()){
				if (t1[j] == 'X')t1[j] = (char)('0' + i);
			}
			REP(j, t2.size()){
				if (t2[j] == 'X')t2[j] = (char)('0' + i);
			}
			REP(j, t3.size()){
				if (t3[j] == 'X')t3[j] = (char)('0' + i);
			}
			reverse(ALL(t1));
			reverse(ALL(t2));
			reverse(ALL(t3));
			if (check(t1, t2, t3)){
				cout << i << endl;
				f = 0;
			}
		}
		if(f)cout << "NA" << endl;
	}
}