#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 f[3];
string s;

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