#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	string str;
	while(cin >> str)
	{
		string s;
		stringstream ss;
		for(char i = '0'; i <= '9'; i++)
		{
			s = str;
			int m;
			while(s.find('X') != string::npos)
			{
				m = s.find('X');
				s[m] = i;
			}
				
			m = s.find('+');
			s.replace(m, 1, " ");
			m = s.find('=');
			s.replace(m, 1, " ");
		
			ss.clear();
			ss.str(s);
			int T[4];

			for(int j = 0; j < 3; j++)
			{
				ss >> T[j];
			}
			
			if(T[0]+T[1] == T[2])
			{
				s = "OK";
				cout << i << endl;
				break;
			}
		}
		if(s != "OK")
		{
			cout << "NA" << endl;
		}
	}
}