#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
struct Int
{
	int a[130];
	Int(){memset(a,0,sizeof(a));}
};
Int add(Int p,Int q)
{
	Int ret;
	int k=0;
	for(int i=0;i<130;i++)
	{
		ret.a[i]=(k+p.a[i]+q.a[i])%10;
		k=(k+p.a[i]+q.a[i])/10;
	}
	return ret;
}
bool same(Int p,Int q)
{
	for(int i=0;i<130;i++)if(p.a[i]!=q.a[i])return false;
	return true;
}
void print(Int p)
{
	for(int i=0;i<130;i++)cout << p.a[i];
	cout << endl;
	return;
}
string s1,s2,s3;
bool check(int k)
{
	//cout << s1 << ' ' << s2 << ' ' << s3 << endl;
	if(k==0&&((s1[s1.size()-1]=='X'&&s1.size()>1)||(s2[s2.size()-1]=='X'&&s2.size()>1)||(s3[s3.size()-1]=='X'&&s3.size()>1)))return false;
	Int p,q,r,sum;
	//cout << "どどどどどーん" << endl;
	for(int i=0;i<130;i++)
	{
		//cout << s1[i];
		if(i<s1.size()&&s1[i]=='X')p.a[i]=k;
		else if(i<s1.size())p.a[i]=s1[i]-'0';
		if(i<s2.size()&&s2[i]=='X')q.a[i]=k;
		else if(i<s2.size())q.a[i]=s2[i]-'0';
		if(i<s3.size()&&s3[i]=='X')r.a[i]=k;
		else if(i<s3.size())r.a[i]=s3[i]-'0';
	}
	//cout << endl;
	//print(p);
	//print(q);
	sum=add(p,q);
	/*for(int i=0;i<130;i++)cout << p.a[i];
	cout << endl;
	for(int i=0;i<130;i++)cout << q.a[i];
	cout << endl;i*/
	//for(int i=0;i<130;i++)cout << sum.a[i];
	//cout << endl;
	//print(sum);
	//print(r);
	return same(sum,r);
}
int main()
{
	string s;
	while(cin >> s)
	{
		//cout << s[0]-'0' << endl;
		int len=s.size();
		s1.clear();s2.clear();s3.clear();
		int index=0;
		for(index=0;index<len;index++)
		{
			if(s[index]=='+')break;
			s1+=s[index];
		}
		index++;
		for(;index<len;index++)
		{
			if(s[index]=='=')break;
			s2+=s[index];
		}
		index++;
		for(;index<len;index++)s3+=s[index];
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		reverse(s3.begin(),s3.end());
		//cout << s1 << ' ' << s2 << ' ' << s3 << endl;
		bool flag=false; 
		for(int i=0;i<10;i++)
		{
			if(check(i))
			{
				cout << i << endl;
				flag=true;
				break;
			}
		}
		if(!flag)cout << "NA" << endl;
		s.clear();
	}
	return 0;
}