#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for (auto it = v.begin(); it != v.end(); ++it)
        os << *it << (it + 1 == v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

bool check(int n, string s){
    rep(i, s.size()){
        if (s[i] == 'X') s[i] = n + '0';
    }
    auto iplus = s.find('+');
    auto ieq = s.find('=');
    string ss[3];
    ss[0] = s.substr(0, iplus);
    ss[1] = s.substr(iplus + 1, ieq - iplus - 1);
    ss[2] = s.substr(ieq + 1);

    int is[3];
    rep(i, 3){
        if (ss[i].size() != 1 && ss[i][0] == '0') return false;
        is[i] = stoi(ss[i]);
    }
    if (is[0]+is[1]==is[2]){
        return true;
    }
}

int main(){
    string s;
    while (cin >> s){
        int ans = -1;
        rep(i, 10){
            if (check(i, s)){
                ans = i;
                break;
            }
        }
        if (ans == -1) cout << "NA";
        else cout << ans;
        cout << endl;
    }
}