#include <iostream>
#include <string>
using namespace std;

int main(void) {
	string str;
	
	while(cin >> str) {
		int ans = -1;
		for(int i = 0; i < 10; i++) {
			string cp(str.begin(), str.end());
			long long a[4] = {0};

			for(int j = 0; j != string::npos;) {
				j = cp.find('X', j);
				if(j != string::npos)
					cp[j] = i + '0';
			}

			for(int j = 0, k = 0; j < cp.size(); k++, j++) {
				while(j < cp.size() && '0' <= cp[j] && cp[j] <= '9') {
					a[k] *= 10;
					a[k] += cp[j++] - '0';
				}
			}

			if(a[0] + a[1] == a[2]) {
				ans = i;
				break;
			}
		}

		if(ans == -1)
			cout << "NA" << endl;
		else
			cout << ans << endl;
	}

	return 0;
}