#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iostream>
using namespace std;

long long int const MOD = 1000000007;

vector<string> split(string s) {
    vector<string> ret;
    string temp;
    replace(s.begin(), s.end(), '+', ' ');
    replace(s.begin(), s.end(), '=', ' ');
    stringstream ss(s);
    while(ss >> temp) ret.push_back(temp);
    return ret;
}

bool solve(vector<string> vs, int x) {
    vector<long long int> res(3);
    for(size_t i=0; i<3; i++) {
        for(size_t j=0; j<vs[i].length(); j++) {
            if(vs[i][j] == 'X') {
                if(x == 0 && j == 0 && vs[i].length() != 1) return false;
                res[i] = (res[i] * 10 + x) % MOD;
            }
            else res[i] = (res[i] * 10 + (vs[i][j] -  '0')) % MOD;
        }
    }
    long long int ra = (res[0] + res[1]) % MOD, rb = res[2];
    return ra == rb;
}

int main() {
    string s;
    while(cin >> s) {
        vector<string> vs = split(s);
        bool ok = false;
        for(int i=0; i<10; i++) {
            if(solve(vs, i)) {
                cout << i << endl;
                ok = true; break;
            }
        }
        if(!ok) cout << "NA" << endl;
    }
}