#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>>

int main(void)
{
	char str[256];
	int xpos[256];
	int xcnt;
	int n;
	
	while (fgets(str, 256, stdin) != NULL){
		xcnt = 0;
		for (int i = 0; str[i] != '\n'; i++){
			if (str[i] == 'X'){
				xpos[xcnt++] = i;
			}
		}
		
		int i;
		for (i = '0'; i <= '9'; i++){
			for (int j = 0; j < xcnt; j++){
				str[xpos[j]] = i;
			}
			int j = 0;
			n = atoi(str);
			while (str[j] != '+')j++;
			j++;
			n += atoi(&str[j]);
			while (str[j] != '=')j++;
			j++;
			if (n == atoi(&str[j])) {
				printf("%c\n", i);
				break;
			}
		}
		if (i == '9' + 1){
			puts("NA");
		}
	}
	
	return (0);
}