#include<iostream>
#include<string>

bool evaluate(const std::string& expression);

int main()
{
	std::string input,expression;
	while(1)
	{
		bool isNA=true;
		std::cin>>input;
		if(std::cin.eof())break;
		
		for(char x='0';x<='9';x++)
		{
			bool correct=false;
			expression=input;
			for(int i=0;i<input.size();i++)
			{
				if(expression[i]=='X'){expression[i]=x;}
			}
			if(evaluate(expression))
			{
				std::cout<<x<<std::endl;
				isNA=false;
			}
		}
		if(isNA)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

bool evaluate(const std::string& expression)
{
	int a[3];//a[0]+a[1]=a[2]
	int numstart,k=0;
	bool innum=false;
	for(int i=0;i<expression.size();i++)
	{
		if(isdigit(expression[i]))
		{
			if(!innum)
			{
				innum=true;
				numstart=i;
			}
		}
		else
		{
			if(innum)
			{
				innum=false;
				a[k]=atoi(expression.substr(numstart,i-numstart).c_str());
				k++;
			}
		}
	}
	a[k]=atoi(expression.substr(numstart).c_str());
	return a[0]+a[1]==a[2];
}