#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int change(string k){
	int res=0;
	rep(i,0,k.size()){
		res+=(k[i]-'0')*pow(10,k.size()-i-1);
	}
	return res;
}

int main(){
	string s;
	while(cin>>s){
		rep(i,0,10){
			string t;
			rep(j,0,s.size()){
				if(s[j]=='X') t[j]='0'+i;
				else t[j]=s[j];
			}
			string a,b,c;
			int x,y;
			rep(j,0,s.size()){
				if(s[j]=='+') x=j;
				if(s[j]=='=') y=j;
			}
			rep(j,0,x) a+=t[j];
			rep(j,x+1,y) b+=t[j];
			rep(j,y+1,s.size()) c+=t[j];
			if(a[0]=='0'||b[0]=='0'||c[0]=='0') continue;
			int d=change(a),e=change(b),f=change(c);
			if(d+e==f){
				o(i); break;
			}
			if(i==9) o("NA");
		}
	}
}