#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n[3];
string s;

int main(){
	while(cin>>s){
		bool f=0;
		for(int i=0;i<10;i++){
			int cur=0,a=0;
			fill(n,n+3,0);
			bool f2=1,f3=0,f4=0;
			while(cur<s.size()){
				if(isdigit(s[cur])){
					n[a]=n[a]*10+s[cur]-'0';
					f2=0;
					if(f3&&!i){f4=1;break;}
				}
				else if(s[cur]=='X'){
					n[a]=n[a]*10+i;
					if(f2)f3=1;
					if(f3&&!i){f4=1;break;}
				}
				else {a++;f2=1;f3=0;}
				cur++;
			}
			if(n[0]+n[1]==n[2]&&!f4){
				cout<<i<<endl;f=1;break;
			}
		}
		if(!f)cout<<"NA"<<endl;
	}
}