#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 
 
const int MAX_V = 10000;


bool calc(vector<string> v, int n){
	for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < v[i].size(); j++){
			if(v[i][j] == 'X') v[i][j] = '0' + n;
		}
	}
	return atoi(v[0].c_str()) + atoi(v[1].c_str()) == atoi(v[2].c_str());
}


int main(){
	string s;
	while(cin>>s){
		vector<string> v;
		int a = s.find("+"), b = s.find("=");
		v.pb(s.substr(0, a));
		v.pb(s.substr(a + 1, b - a - 1));
		v.pb(s.substr(b  + 1));
		int ans = -1;
		for(int i = 9; i >= 0; i--){
			if(calc(v, i)){
				ans = i;
				break;
			}
		}
		if(ans == -1) cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
}