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

int to_number(string str, char c){
	int n=0;
	for(int i=0 ; i < str.size() ; i++ ){
		if( str[i] == 'X' ){
			str[i] = c;
		}
	}
	for(int i=0 ; i < str.size() ; i++ ){
		n *= 10;
		n += str[i]-'0';
	}
	return n;
}

void solve(string s){
	string num1, num2, num3;
	int plus, equal;
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == '+' )
			plus = i;
		if( s[i] == '=' )
			equal = i;
	}
	num1 = s.substr( 0 , plus );
	num2 = s.substr( plus+1 , equal-plus-1 );
	num3 = s.substr( equal+1 );
	for(int i=0 ; i <= 9 ; i++ ){
		int a = to_number( num1 , i+'0' );
		int b = to_number( num2 , i+'0' );
		int c = to_number( num3 , i+'0' );
		if( a+b == c ){
			cout << i << endl;
			return;
		}
	}
	cout << "NA" << endl;
}

int main(){
	string s;
	while( cin >> s ){
		solve( s );
	}
}