#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

vector<string> split( const string &str, const string &delim = " " )
{
	vector<string> result;
	int start = 0, pos;

	while ( ( pos = str.find_first_of( delim, start ) ) != string::npos )
	{
		result.push_back( str.substr( start, pos - start ) );
		start = pos + 1;
	}

	return result;
}

bool leadingX( string expr )
{
	VS words = split( expr );
	return any_of( ALL( words ), []( string s ){ return 2 <= s.size() && s[0] == 'X'; } );
}

string solve( string expr )
{
	replace_if( ALL( expr ), []( char c ){ return c == '+' || c == '='; }, ' ' );

	for ( char ch = ( leadingX( expr ) ? '1' : '0' ); ch <= '9'; ch++ )
	{
		string tmp;
		replace_copy( ALL( expr ), back_inserter( tmp ), 'X', ch );
		
		int a, b, c;
		ISS iss( tmp );
		iss >> a >> b >> c;

		if ( a + b == c )
		{
			return string() + ch;
		}
	}

	return "NA";
}	

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	string str;
	
	while ( cin >> str )
	{
		cout << solve( str ) << endl;
	}

	return 0;
}