#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(){
	char t[150];
	int a,b,c;
	while(cin>>t){
		int i;
		char s[150];
		s[strlen(t)]='\0';
		for(i=0;i<10;i++){
			for(int j=0;j<strlen(t);j++){
				if(t[j]=='X')
					s[j]='0'+i;
				else
				s[j]=t[j];
			}
			for(int j=0;j<strlen(t);j++){
				a=atoi(s);
				if(a>0&&s[0]=='0')
				continue;
				if(s[j]=='+'){
					b=atoi(&s[j+1]);
					if(b>0&&s[j+1]=='0')
					continue;
				}
				if(s[j]=='='){
				c=atoi(&s[j+1]);
					if(c>0&&s[j+1]=='0')
					continue;
				}
			}
			
			if(a+b==c){
				cout<<i<<endl;
				break;
			}
		}
		if(i==10)
		cout<<"NA"<<endl;
	}
	return 0;
}