#include <iostream>
#include <string>

using namespace std;

int main() {
	string a;
	while (getline(cin, a)) {
		bool hantei = true;
		for (int i = 0; i < 10; i++) {
			int b[3] = {0};
			int counter = 0;
			bool hantei2 = true;
			for (int j = 0; j < a.size(); j++) {
				if (a[j] == '+') {
					counter++;
				} else if (a[j] == '=') {
					counter++;
				} else if (a[j] == 'X') {
					if (j == 0 && i == 0) {
						hantei2 = false;
						break;
					}
					b[counter] *= 10;
					b[counter] += i;
				} else {
					b[counter] *= 10;
					b[counter] += a[j]-'0';
				}
			}
			if (b[0]+b[1] == b[2] && hantei2) {
				cout << i << endl;
				hantei = false;
				break;
			}
		}
		if (hantei) {
			cout << "NA" << endl;
		}
	}
	return 0;
}