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

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_N 20000
#define MAX_M 16

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;
bool f1[200], f2[200], f3[200];

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

int main(){
	while (cin >> s){
		fill(f1, f1 + 200, 0);
		fill(f2, f2 + 200, 0);
		fill(f3, f3 + 200, 0);
		int pos = 0;
		string t1, t2, t3;
		REP(i, s.size()){
			if (s[i] == '+'){
				t1 = s.substr(pos, i);
				pos = i + 1;
			}
			else if (s[i] == '='){
				t2 = s.substr(pos, i - pos);
				pos = i + 1;
			}
			if (i == s.size() - 1){
				t3 = s.substr(pos);
			}
		}
		REP(i, t1.size()){
			if (t1[i] == 'X')f1[i] = 1;
		}		
		REP(i, t2.size()){
			if (t2[i] == 'X')f2[i] = 1;
		}		
		REP(i, t3.size()){
			if (t3[i] == 'X')f3[i] = 1;
		}
		FOR(i, 1, 10){
			ll a, b, c;
			REP(j, t1.size()){
				if (f1[j])t1[j] = (char)('0' + i);
			}
			REP(j, t2.size()){
				if (f2[j])t2[j] = (char)('0' + i);
			}			
			REP(j, t3.size()){
				if (f3[j])t3[j] = (char)('0' + i);
			}
			a = changei(t1);
			b = changei(t2);
			c = changei(t3);
			if (a + b == c){
				cout << i << endl;
				break;
			}
			if (i == 9){
				cout << "NA" << endl;
			}
		}

	}
}