#include<iostream>
#include<string>
using namespace std;

#define max(a,b) (a>b?a:b)

#define leftzero(n) (num[n][dig[n]-1]==-1&&dig[n]>1)
#define altx(n,i) (num[n][i]==-1?x:num[n][i])

int main() {
	int num[3][126], dig[3], n, c;
	int car, tmp, ans;
	string str;
	while(cin >> str) {
		c = 2; n = 0;
		for(int i=(signed)str.length()-1; i>=0; --i) {
			if(str[i]=='=' || str[i]=='+') {
				c--; n = 0;
			}else {
				num[c][n] = str[i]=='X'?-1:(int)(str[i]-'0');
				dig[c] = ++n;
			}
		}
		ans = -1;
		if(max(dig[0], dig[1])<=dig[2]) for(int x=0; x<=9&&ans==-1; ++x) {
			if(!x&&(leftzero(0)||leftzero(1)||leftzero(2))) continue;
			ans = x; car = 0;
			for(int i=0; i<dig[2]; ++i) {
				tmp = (i<dig[0]?altx(0,i):0)+(i<dig[1]?altx(1,i):0)+car;
				if((tmp%10)!=altx(2,i)) {
					ans = -1; break;
				}
				car = tmp/10;
			}
			if(car) ans = -1;
		}
		if(ans==-1) cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}