#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int int_pow(int n,int m){
	int ans = 1;
	while(m--) ans *= n;
	return ans;
}

int main(){
	while(true){
		vector<int> n[3];
		char C;
		int r;
		int cnt = 0;
		while(true){
			r = scanf("%c",&C);
			if(r==EOF) return 0;
			if(C=='\n') break;
			else if(C=='+' || C=='=') cnt++;
			else if(C=='X') n[cnt].push_back(-1);
			else n[cnt].push_back(C-'0');
		}
		bool na = true;
		for(int t=0;t<9;t++){
			int n_[3] = {};
			for(int i=0;i<3;i++){
				for(int j=0;j<n[i].size();j++){
					int a = n[i][n[i].size()-j-1];
					if(a==-1) a = t;
					n_[i] += a*int_pow(10,j);
				}
			}
			if(n_[0]+n_[1]==n_[2]){
				printf("%d\n",t); na = false; break;
			}
		}
		if(na) puts("NA");
	}
}