#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	string s;
	while (cin >> s){
		int n[3];
		REP(i,s.length()){
			if (s[i] == '+')
				n[0] = i;
			if (s[i] == '='){
				n[1] = i - n[0] - 1;
				n[2] = s.length() - n[0] - n[1] - 2;
				break;
			}
		}
		int ans = -1;
		REP(i, 10){
			string s2 = s;
			REP(j, s2.length()){
				if (s2[j] == 'X')
					s2[j] = i + '0';
			}
			if ((s2[0] == '0'&&n[0]>1) ||( s2[n[0] + 1] == '0'&&n[1]>1) || (s2[n[0] + n[1] + 2] == '0'&&n[2]>1))
				continue;
			int num[128] = {0};
			for (int j = 0; j < 128; j++){
				if (j < n[0])
					num[j]+=s2[n[0]-j-1]-'0';
				if (j < n[1])
					num[j] += s2[n[0]+n[1] - j] - '0';
				if (j < n[2])
					num[j] -= s2[s2.length()-1-j] - '0';
				if (num[j] != 0 && num[j] != 10)
					break;
				else{
					if (num[j] == 10)
						num[j + 1]++;
					num[j] = 0;
				}
			}
			bool b = true;
			REP(j, 128){
				if (num[j] != 0)
					b = false;
			}
			if (b){
				ans = i;
				break;
			}
		}
		if (ans != -1)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
}