#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
	string in;
	while ( cin >> in )
	{
		bool found = false;
		for ( int i = 0; i < 10; i++ )
		{
			string ex = in;
			replace( ex.begin(), ex.end(), 'X', (char)('0'+i) );
			replace( ex.begin(), ex.end(), '+', ' ' );
			replace( ex.begin(), ex.end(), '=', ' ' );

			istringstream is(ex);
			string a, b, c;
			is >> a >> b >> c;

			if ( a[0] == '0' || b[0] == '0' || c[0] == '0' )
				continue;

			istringstream is2( ex );
			int aa, bb, cc;
			is2 >> aa >> bb >> cc;
			
			if ( aa + bb == cc )
			{
				cout << i << endl;
				found = true;
				break;
			}
		}

		if ( found == false )
			cout << "NA" << endl;
		
	}
	return 0;
}