#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>

using namespace std;

typedef enum {
	EMPTY,
	INTX,
	PLUS,
	EQ,
	_EOF
} token_kind_t;

class token{
public:
	int c;
	token_kind_t kind;
	string str;

	token();
	token next_tok();
};

token::token(){
	c = 0;
	kind = EMPTY;
	str.clear();
}

token token::next_tok()
{
	while (c == ' ' || c == '\n') {
		c = getchar();
	}
	if (isdigit(c) || c == 'X'){
		str.clear();
		kind = INTX;
		while (isdigit(c) || c == 'X'){
			char buf[2];
			buf[0] = c; buf[1] = 0;
			str.append(buf);
			c = getchar();
		}
	}
	else if (c == EOF){
		kind = _EOF;
		exit(0);
	}
	else{
		if (c == '+') kind = PLUS;
		else if (c == '=') kind = EQ;
		else exit(1);

		c = getchar();
	}

	return *this;
}

int fill(string &op, int X)
{
	int ret = 0;

	for (int i = 0; i < op.size(); i++){
		ret *= 10;
		if (op.at(i) == 'X'){
			ret += X;
		}
		else {
			ret += op.at(i) - '0';
		}
	}
	return ret;
}

void alphametic(string &op1, string &op2, string &op3)
{
	for (int X = 0; X < 10; X++){
		if (X == 0){
			if (op1.at(0) == 'X' || op2.at(0) == 'X' || op3.at(0) == 'X') continue;
		}
		int iop1 = fill(op1, X);
		int iop2 = fill(op2, X);
		int iop3 = fill(op3, X);
		if (iop1 + iop2 == iop3){
			cout << X << endl;
			return;
		}
	}
	cout << "NA" << endl;
}

int main()
{
	token t;

	t.c = getchar();
	t.next_tok();
	while (t.c != EOF){
		string op1 = t.str;
		t.next_tok();
		if (t.kind != PLUS) exit(1);
		t.next_tok();
		string op2 = t.str;
		t.next_tok();
		if (t.kind != EQ) exit(1);
		t.next_tok();
		string op3 = t.str;
		alphametic(op1, op2, op3);
		t.next_tok();
	}
	return 0;
}