#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

//???????????????2?????????????????????1???

int main(){

	int left_length,right_length,ans_length,left[150],left_X[150],right[150],right_X[150],sum_left[150],left_work_X[150],sum_right[150],right_work_X[150],loop;
	bool FirstFLG,ansFound;
	char buf[150];

	while(scanf("%s",buf)!=EOF){

		for(int i = 0; i < 150; i++){
			left[i] = 0; //?????????????????????????????°
			left_X[i] = 0;
			right[i] = 0; //?????????????????????????????°
			right_X[i] = 0;
		}


		//?????????????????°?????????
		for(left_length = 0;buf[left_length]!='+';left_length++);
		//?????????????????°?????????
		for(right_length = 0;buf[left_length+1+right_length] != '=';right_length++);
		//????????????????????°?????????
		for(ans_length = 0;buf[left_length+1+right_length+1+ans_length]!='\0';ans_length++);

		FirstFLG = false;	//X???????????????????????????????????????<???????????????0??§???????????????X?????????????????????????????????X???0??§?????????>

		//?????????????????????????§£??????
		for(int i = 0; i < left_length;i++){
			if(buf[i] >= '0' && buf[i] <= '9'){
				left[left_length-i-1] += (buf[i]-'0');	//??????????????°????¶????<?????°???????????????????????????>
			}else{
				left_X[left_length-i-1]++;	//X??????????????????????¨??????????
				if(i == 0 && left_length > 1)FirstFLG = true; //???1?????????0??§???OK!
			}
		}

		//?????????????????????????§£??????
		for(int i = 0; i < right_length;i++){
			if(buf[left_length+1+i] >= '0' && buf[left_length+1+i] <= '9'){
				left[right_length-1-i] += (buf[left_length+1+i]-'0');
			}else{
				left_X[right_length-1-i]++;
				if(i == 0 && right_length > 1)FirstFLG = true; //???1?????????0??§???OK!
			}
		}

		//?????????????§£??????
		for(int i = 0; i < ans_length; i++){
			if(buf[left_length+1+right_length+1+i] >= '0' && buf[left_length+1+right_length+1+i] <= '9'){
				right[ans_length-1-i] += (buf[left_length+1+right_length+1+i] -'0');
			}else{
				right_X[ans_length-1-i]++;
				if(i == 0 && ans_length > 1)FirstFLG = true; //???1?????????0??§???OK!
			}
		}


		//???????????°??????????????°???????????????????????????
		for(int i = 0; i <=130;i++){
			if(left[i] >= 10){
				left[i+1] += left[i]/10;
				left[i] %= 10;
			}
		}

		if(FirstFLG){
			loop = 1; //????????????????????????X??????????????????0???????????§?????????
		}else{
			loop = 0;
		}

		ansFound = false;
		for(; loop <= 9; loop++){
			for(int i = 0; i < 150; i++){
				sum_left[i] = left_work_X[i] = sum_right[i] = right_work_X[i] = 0;
			}

			//??????????????????X?????°??????
			for(int i = 0; i <= 130;i++){
				if(left_X[i] > 0){
					left_work_X[i] += loop*left_X[i];

					if(left_work_X[i] >= 10){ //??°??????????????????
						left_work_X[i+1] += left_work_X[i]/10;
						left_work_X[i] %= 10;
					}
				}
			}

			//?????????????????????
			for(int i = 0; i <= 130;i++){
				sum_left[i] += left[i] + left_work_X[i];
				if(sum_left[i] >= 10){
					sum_left[i+1] += sum_left[i]/10;
					sum_left[i] %= 10;
				}
			}

			//?????????X?????°??????
			for(int i = 0; i <= 130; i++){
				if(right_X[i] > 0){
					right_work_X[i] += loop*right_X[i];

					if(right_work_X[i] >= 10){
						right_work_X[i+1] += right_work_X[i]/10;
						right_work_X[i] %= 10;
					}
				}
			}

			//?????????????????????
			for(int i = 0; i <= 130; i++){
				sum_right[i] += right[i] + right_work_X[i];
				if(sum_right[i] >= 10){
					sum_right[i+1] += sum_right[i]/10;
					sum_right[i] %= 10;
				}
			}

			ansFound = true;
			//???????????????
			for(int i = 0; i <= 130; i++){
				if(sum_left[i] != sum_right[i]){
					ansFound = false;
					break;
				}
			}

			if(ansFound){
				printf("%d\n",loop);
				break;
			}

		}
		if(!ansFound)printf("NA\n");

	}


    return 0;
}

Measured memory_bytes: 3152