#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;
typedef long long ll;

int main(void) {
	string s,bck;

	while (cin >> s) {
		int flag = 0;
		long long before = 0;
		long long after = 0;
		for (int i = 0; i < s.length(); ++i) {
			bck[i]=s[i];
		}
		for (int cnt = 0; cnt < 10; ++cnt) {
			for (int i = 0; i < s.length(); ++i) {
				if (s[i] == '+') {
					before = i;
				} else if (s[i] == '=') {
					after = i;
				} else if (s[i] == 'X') {
					s[i] = cnt + '0';
				}
			}
			long long beforev = 0;
			for (int i = 0; i < before; ++i) {
				beforev *= 10;
				beforev += s[i] - '0';
			}
			long long afterv = 0;
			for (int i = before + 1; i < after; ++i) {
				afterv *= 10;
				afterv += s[i] - '0';
			}
			long long sumv = 0;
			for (int i = after + 1; i < s.length(); ++i) {
				sumv *= 10;
				sumv += s[i] - '0';
			}
			if (sumv == (beforev + afterv)) {
				printf("%d\n",cnt);
				flag = 1;
				break;
			}
			for (int j = 0; j < s.length(); ++j) {
				s[j]=bck[j];
			}
		}
		if (flag == 0) {
			cout << "NA" << endl;
		}
	}
}