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

long long stoi(string s)
{
	stringstream ss(s);
	long long  ans;
	ss>>ans;
	return ans;
}

int main()
{
	string in;
	while(cin>>in) 
	{
		bool zero_f=true;
		vector<int> pos;
		int ppos,epos;
		for(int i = 0; i < in.size(); ++i)
		{
			if(in[i]=='=') epos=i;
			if(in[i]=='+') ppos=i;
			if(in[i]=='X')
			{
				pos.push_back(i);
				if( (i==0&&in[1]!='+') || (in[i-1]=='+'&&in[i+1]!='=') || (in[i-1]=='=' && i+1!=in.size()) ) zero_f=false;
			}
		}
		bool f=false;
		for(int i = zero_f?0:1; i < 10; ++i)
		{
			for(int j = 0; j < pos.size(); ++j)
			{
				in[pos[j]]=i+'0';
				if(stoi(in.substr(0,ppos))+stoi(in.substr(ppos+1,epos-ppos-1))==stoi(in.substr(epos+1,in.size()-epos-1)))
				{
					cout<<i<<endl;
					f=true;
				}
			}
		}
		if(!f) cout<<"NA"<<endl;
	}
  return 0;
}