#include<iostream>
#include<cstdio>
#include<vector>
#include<cstdlib>
using namespace std;
#define satoi(n) atoi(n.c_str())
bool func(vector<string> f , int n){
	for(int i=0;i<3;i++){
		for(int j=0;j<f[i].length();j++){
			if(f[i][j]=='X'){
				f[i][j]='0'+n;
			}
		}
	}
	if(satoi(f[0])+satoi(f[1]) == satoi(f[2]))return true;
	else false;
}

int main(){
	bool flag;
	int ret;
	vector<string> m;
	string s,t;
	while(cin >> s){
		s+=" ";
		m.clear();
		flag = false;
		ret = -1;
		
		for(int i=0;i<s.length();i++){
			if(s[i]>='0' && s[i]<='9' || s[i]=='X'){
				t+=s[i];
			}else{
				if(t[0] == 'X')flag = true;
				m.push_back(t);
				t.clear();
			}
		}
		for(int i=(flag?1:0);i<10;i++){
			if(func(m,i))ret=i;
		}
		if(~ret)cout << ret << endl;
		else cout << "NA" << endl;
	}
}