#include<algorithm>
#include<iostream>
#include<string>
#include<vector>

typedef std::vector<int> BigInt;

std::string expr;
std::string::size_type idx;

/*
BigInt fromNum( int n )
{
	BigInt ret;
	while( n > 0 )
	{
		ret.push_back( n % 10 );
		n /= 10;
	}

	return ret;
}

void show( const BigInt& n )
{
	for( int i = n.size() - 1; i >= 0; --i )
		std::cout << n[i];
	std::cout << std::endl;

	return;
}*/

BigInt add( BigInt& a, BigInt& b )
{
	BigInt& mi = a.size() < b.size() ? a : b;
	mi.resize( std::max( a.size(), b.size() ) );

	BigInt ret( a.size() + 1 );
	for( int i = 0; i != a.size(); ++i )
	{
		ret[i] += a[i] + b[i];
		
		if( ret[i] > 9 )
			ret[i] -= 10, ++ret[i+1];
	}

	if( !ret[a.size()] )
		ret.resize( a.size() );

	return ret;
}

BigInt number( const std::string& s )
{
	BigInt ret;
	while( idx < s.size() && s[idx] >= '0' && s[idx] <= '9' )
		ret.push_back( s[idx++] - '0' );

	std::reverse( ret.begin(), ret.end() );

	return ret;
}

bool check( const std::string& s )
{
	BigInt p = number( s );
	
	++idx;
	
	BigInt q = number( s );
	
	++idx;

	BigInt r = number( s );
	
	return add( p, q ) == r;
}

std::string replaceX( int n )
{
	std::string ret = expr;
	std::string::size_type i;

	while( ( i = ret.find( "X" ) ) != std::string::npos )
	{
		char str[2] = { n + '0', '\0' };
		ret.replace( i, 1, str ); 
	}

	return ret;
}

int main()
{
	while( std::cin >> expr )
	{
		int ans = -1;

		for( int i = 0; i <= 9; ++i )
		{
			idx = 0;
			if( check( replaceX( i ) ) )
			{
				ans = i;
				break;
			}
		}

		if( ans < 0 )
			std::cout << "NA" << std::endl;
		else
			std::cout << ans << std::endl;
	}

	return 0;
}