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

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 {
				if(str[i]=='X') num[c][n] = -1;
				else num[c][n] = (int)(str[i]-'0');
				n++; dig[c] = n;
			}
		}
		car = 0; ans = -1;
		for(int x=0; x<=9&&ans==-1; ++x) {
			if(!x&&(num[0][dig[0]-1]==-1||num[1][dig[1]-1]==-1||num[2][dig[2]-1]==-1)) continue;
			ans = x;
			for(int i=0; i<dig[2]; ++i) {
				tmp = (i<dig[0]?num[0][i]==-1?x:num[0][i]:0)+(i<dig[1]?num[1][i]==-1?x:num[1][i]:0)+car;
				if((tmp%10)!=(num[2][i]==-1?x:num[2][i])) {
					ans = -1; break;
				}
				car = tmp/10;
			}
		}
		if(ans==-1) cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}