#include <iostream>
#include <cstdio>
#include <cstdlib>
#define X 126
using namespace std;

int main(){
	char h;
	int a[X],b[X],c[X];
	int n[3];
	while(1){
		for(int i=0;i<X;i++){ a[i] = 0; b[i] = 0; c[i] = 0;}
		n[0] = 0;
		while(1){
			cin >> h;
			if(cin.eof()) return 0;
			if(h=='+') break;
			else if(h=='X') a[n[0]] = -1;
			else a[n[0]] = atoi(&h);
			n[0]++;
		}
		n[1] = 0;
		while(1){
			cin >> h;
			if(h=='=') break;
			else if(h=='X') b[n[1]] = -1;
			else b[n[1]] = atoi(&h);
			n[1]++;
		}
		n[2] = 0;
		while(1){
			scanf("%c",&h);
			if(h=='\n') break;
			else if(h=='X') c[n[2]] = -1;
			else c[n[2]] = atoi(&h);
			n[2]++;
		}
		int y = -1;
		for(int i=0;i<10;i++){
			int ta[X],tb[X],tc[X];
			for(int j=0;j<X;j++){
				if(j<n[0]) ta[X-n[0]+j] = a[j];
				else ta[X-j-1] = a[j];
				if(j<n[1]) tb[X-n[1]+j] = b[j];
				else tb[X-j-1] = b[j];
				if(j<n[2]) tc[X-n[2]+j] = c[j];
				else tc[X-j-1] = c[j];
			}
			for(int j=0;j<X;j++) if(ta[j]==-1) ta[j] = i;
			for(int j=0;j<X;j++) if(tb[j]==-1) tb[j] = i;
			for(int j=0;j<X;j++) if(tc[j]==-1) tc[j] = i;
			int k = 0;
			bool z = true;
			for(int j=X-1;j>=0;j--){
				if((ta[j]+tb[j]+k)%10!=tc[j]) z = false;
				if(not z) break;
				k = 0;
				if(ta[j]+tb[j]+k>9) k = 1;
			}
			if(z) y = i;
		}
		if(y==-1) cout << "NA" << endl;
		else cout << y << endl;
	}
}