#include <iostream>
#include <cctype>
#include <string>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int idx;
string s;

int Num(){
    int res=0;
    while(isdigit(s[idx])){
        res=res*10 + s[idx] - '0';
        idx++;
    }
    idx++;
    return res;
}

int main(){
    string t;
    while(cin>>t){
        s=t;
        int ans=-1;
        rep(i,10){
            if(i==0 && (s[0]=='X' || s[s.find('+')+1]=='X' || s[s.find('=')+1]=='X')) continue;
            rep(k,s.size()) if(s[k]=='X') s[k]='0'+i;
            idx=0;
            if(Num()+Num()==Num()){
                ans=i; break;
            }
            s=t;
        }
        if(ans!=-1) cout<<ans<<endl;
        else cout<<"NA"<<endl;
    }
}