#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


ll get_num(string num, int x)
{
	if (num[0] == 'X' && x == 0 && num.length() >= 2) return -99999999999999999999;
	ll ret = 0;
	rep(i, num.length())
	{
		if (num[i] == 'X')
		{
			ret = ret * 10 + x;
		} else {
			ret = ret * 10 + num[i] - '0';
		}
	}
	return ret;
}


int main()
{
	string inp, a, b, c;
	
	while (cin >> inp)
	{
		a = inp.substr(0, inp.find("+"));
		b = inp.substr(inp.find("+") + 1, inp.find("=") - inp.find("+") - 1);
		c = inp.substr(inp.find("=") + 1);
		
		bool flag = false;
		rep(i, 10)
		{
			if (get_num(a, i) == -99999999999999999999 || get_num(b, i) == -99999999999999999999 || get_num(c, i) == -99999999999999999999)
				continue;
			if (get_num(a, i) + get_num(b, i) == get_num(c, i))
			{
				cout << i << endl;
				flag = true;
				break;
			}
		}
		if (!flag) cout << "NA" << endl;
	}
	
	return 0;
}


bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}