#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

bool ok(int n, string s){
    rep(i,s.size())if(s[i]=='X') s[i] = n+'0';
    if(n==0){
        if(s[0]=='0') return false;
        if(s[s.find('+')+1]=='0') return false;
        if(s[s.find('=')+1]=='0') return false;
    }

    stringstream ss(s);
    int a,b,c;
    char op;
    ss >> a >> op >> b >> op >> c;
    return a+b==c;
}

int main(){
    string s;
    while(cin >> s){
        rep(i,10){
            if(ok(i,s)){
                cout << i << endl;
                goto end;
            }
        }
        cout << "NA" << endl;
    end:;
    }
}