#include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	string n;
	while(cin >> n){
		if(cin.eof()) break;
		int it=0;
		string a="",b="",c="";
		while(n[it]!='+') a+=n[it++];it++;
		while(n[it]!='=') b+=n[it++];it++;
		while(it<n.size()) c+=n[it++];

		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		reverse(c.begin(),c.end());


		int ans=-1;

		rep(d,10){
			string ca=a,cb=b,cc=c;
			rep(i,ca.size()) if(ca[i]=='X') ca[i]=d+'0';
			rep(i,cb.size()) if(cb[i]=='X') cb[i]=d+'0';
			rep(i,cc.size()) if(cc[i]=='X') cc[i]=d+'0';

			if(d==0&&ca.size()>=2&&ca[ca.size()-1]=='0') continue;
			if(d==0&&cb.size()>=2&&cb[cb.size()-1]=='0') continue;
			if(d==0&&cc.size()>=2&&cc[cc.size()-1]=='0') continue;

			string sum="";
			int carry=0,m=cc.size();
			rep(i,m){
				int cur=carry;
				if(i<ca.size()) cur+=(ca[i]-'0');
				if(i<cb.size()) cur+=(cb[i]-'0');
				carry=cur/10;
				sum+=(cur%10+'0');
			}
			if(carry==0&&sum==cc){
				ans=d;
			}
		}
		if(ans==-1)
			cout << "NA" << endl;
		else
			cout << ans << endl;
	}
	return 0;
}