#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 998244353;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


int main() {
    string s;
    auto solve = [](string &a, string &b, string &c, int val){
        ll x = 0, y = 0, z = 0;
        for (auto &&i : a) x = (x*10 + (isdigit(i) ? i-'0' : val))%MOD;
        for (auto &&i : b) y = (y*10 + (isdigit(i) ? i-'0' : val))%MOD;
        for (auto &&i : c) z = (z*10 + (isdigit(i) ? i-'0' : val))%MOD;
        return (x+y)%MOD == z%MOD;
    };
    while(cin >> s){
        string A, B, C;
        int cur = 0;
        for (auto &&i : s) {
            if(i == '+' || i == '=') cur++;
            else if(cur == 0) A += i;
            else if(cur == 1) B += i;
            else C += i;
        }
        int ok = 0;
        for (int i = ((A.size() != 1 && A[0] == 'X') || (B.size() != 1 && B[0] == 'X') ||  (C.size() != 1 && C[0] == 'X')); i < 10; ++i) {
            if(solve(A, B, C, i)) {
                cout << i << "\n";
                ok = 1;
                break;
            }
        }
        if(!ok) puts("NA");
    }
    return 0;
}

