#include <cstdio>
#include <cstring>

const int MOD = 100000007;
char text[130];

bool solve(int s, int t, int x) {
    int cur = s, val = 0, vl = 0, vr = 0;
    while(cur < t) {
        if(text[cur] == 'X') val = (val * 10 + x) % MOD;
        else if(text[cur] == '+') (vl += val) %= MOD, val = 0;
        else if(text[cur] == '=') (vl += val) %= MOD, val = 0;
        else val = (val * 10 + (text[cur] - '0')) % MOD;
        cur++;
    }
    (vr += val) %= MOD;
    // printf("x = %d, vl = %d, vr = %d\n", x, vl, vr);
    return vl == vr;
}

int main() {
    while(scanf("%s", text) != EOF) {
        int N = strlen(text);
        bool ok = false;
        for(int i=0; i<10; i++) {
            if(solve(0, N, i)) {
                printf("%d\n", i);
                ok = true;
                break;
            }
        }
        if(!ok) printf("NA\n");
    }
}