#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999

int main(){
    string s;
    while(cin>>s){
        string a[3];
        int c=0;
        rep(i,s.size()){
            if(s[i]!='+' && s[i]!='='){
                a[c]+=s[i];
            }
            else{
                c++;
            }
        }
        bool f=true;
        rep(i,10){
            string x=a[0],y=a[1],z=a[2];
            rep(j,x.size())if(x[j]=='X')x[j]='0'+i;
            rep(j,y.size())if(y[j]=='X')y[j]='0'+i;
            rep(j,z.size())if(z[j]=='X')z[j]='0'+i;
            if(stoi(x)+stoi(y)==stoi(z)){
                cout<<i<<endl;
                f=false;
                break;
            }
        }
        if(f)cout<<"NA"<<endl;
    }
}