#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

vector<string> split(const string &str, char delim)
{
  vector<string> res;
  size_t current = 0, found;
  while((found = str.find_first_of(delim, current)) != string::npos)
  {
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

vector<char> splus(string s,string s1)
{

	reverse(s.begin(),s.end());
	reverse(s1.begin(),s1.end());

	while(s.size() > s1.size())
	{
		s1 += '0';
	}

	while(s1.size() > s.size())
	{
		s += '0';
	}

	reverse(s.begin(),s.end());
	reverse(s1.begin(),s1.end());

	vector<char> ans;

	int up = 0;
	for(int i=s.size()-1 ; i >= 0;i--)
	{
		int t = (s[i] - '0') + (s1[i] - '0');
		if(up == 0)
		{
			if(t > 9)
			{
				up = (t/10);
				t %= 10;
				ans.push_back(t + '0');
			}
			else
			{
				ans.push_back(t + '0');
			}
		}
		else
		{
			t += up;
			up = 0;

			if(t > 9)
			{
				up = t/10;
				t %= 10;
				ans.push_back(t + '0');
			}
			else
			{
				ans.push_back(t + '0');
			}
		}
	}
	if(up != 0)
	{
		ans.push_back(up + '0');
		up = 0;
	}

	reverse(ans.begin(),ans.end());
	return ans;
}

int main()
{
	string s;
	while(cin >> s)
	{
		vector<string> _s = split(s,'+');
		vector<string> _s_1 = split(_s[1],'=');

		bool flag = true;
		rep(i,10)
		{
			string a = _s[0];
			string b = _s_1[0];
			string c = _s_1[1];

			if(a[0] == 'X' || b[0] == 'X' || c[0] == 'X')
			{
				i++;
			}			

			rep(j,a.size())
			{
				if(a[j] == 'X') a[j] =  i + '0';
			}

			rep(j,b.size())
			{
				if(b[j] == 'X') b[j] = i + '0';
			}

			rep(j,c.size())
			{
				if(c[j] == 'X') c[j] = i + '0';
			}

			vector<char> temp = splus(a,b);
			bool ok = true;
			rep(i,temp.size())
			{
				if(temp[i] != c[i])
				{
					ok = false;
				}
			}

			if(ok)
			{
				flag = false;
				cout << i << endl;
				break;
			}
		}

		if(flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}