#include <iostream>
#include <cstring>
#include <cctype>

int main()
{
	const int N = 128;
	char str[N];
	
	while (std::cin >> str) {
		int cs[N] = {0}, vs[N] = {0};
		int sFlag = 1, xFlag = 0, zeroFlag = 0, cDigit = 0, maxDigit = 0;;
		
		for (int i = strlen(str) - 1; i >= 0; --i) {
			if (isdigit(str[i])) {
				xFlag = 0;
				
				cs[cDigit] += sFlag * (str[i] - '0');
				if (cs[cDigit] < -9 || 9 < cs[cDigit]) {
					cs[cDigit] %= 10;
					cs[cDigit + 1] += sFlag;
				}
				++cDigit;
			} else {
				switch (str[i]) {
				case '=':
					sFlag = -1;
				case '+':
					if (cDigit > maxDigit) {
						maxDigit = cDigit;
						zeroFlag = xFlag;
					}
					cDigit = 0;
					break;
				case 'X':
					vs[cDigit++] -= sFlag;
					xFlag = 1;
					break;
				default:
					break;
				}
			}
		}
		
		
		int b;
		for (b = 0; vs[b] == 0; ++b);
		
		int ans = cs[b] / vs[b];
		
		if (ans != 0 || maxDigit < 2 || zeroFlag == 0) {
			for (int i = 0; i < maxDigit; ++i) {
				if (cs[i] != vs[i] * ans) {
					ans = -1;
					break;
				}
			}
		} else {
			std::cout << "kotti\n";
			ans = -1;
		}
		
		if (ans == -1) {
			std::cout << "NA";
		} else {
			std::cout << ans;
		}
		std::cout << std::endl;
	}
	
	return 0;
}