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

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 Num(const string &s, int &i){
    int res = 0;
    while (isdigit(s[i])){
        res *= 10;
        res += s[i] - '0';
        i++;
    }
    return res;
}

bool ok(const string & s){
    int i = 0;
    int lhs = Num(s, i);
    i++;
    lhs += Num(s, i);
    i++;
    int rhs = Num(s, i);
    return rhs == lhs;
}

int main(){
    string origin;
    while (getline(cin, origin)){
        int ans = -1;
        rep(i, 10){
            string s = origin;
            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;
            if (ok(s)){
                ans = i;
                break;
            }
        }
        if (ans != -1) cout << ans << endl;
        else cout << "NA" << endl;
    }
}