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

bool chksum(string a,string b,string c)
{
	bool up=false;
	int now=0;
	int apos=a.size()-1,bpos=b.size()-1;
	
	for(int i = c.size()-1; i >= 0; --i)
	{
		now=0;
		if(apos>=0)
		{
			now+=a[apos]-'0';
			apos--;
		}
		if(bpos>=0)
		{
			now+=b[bpos]-'0';
			bpos--;
		}
		if(up)
		{
			now++; up=false;
		}
		if(now>=10)
		{
			up=true;
			now%=10;
		}
		if(now!=c[i]-'0') return false;
	}
	if(apos!=-1||bpos!=-1) return false;
	return true;
}

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(chksum(in.substr(0,ppos),in.substr(ppos+1,epos-ppos-1),in.substr(epos+1,in.size()-epos-1)))
			{
				cout<<i<<endl;
				f=true;
				break;
			}
			if(f) break;
		}
		if(!f) cout<<"NA"<<endl;
	}
  return 0;
}