#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int assignX(string s, int x) {
    replace(s.begin(), s.end(), 'X', (char)(x + '0'));
    return atoi(s.c_str());
}

bool c(string s) { return s[0] == 'X' && s.size() > 1; }

int main () {
    string s, x, y, ans;

    while(cin >> s) {
        int pos  = -1;
        int eq   = s.find("=");
        int plus = s.find("+");

        x   = s.substr(0, plus);
        y   = s.substr(plus + 1, eq - plus - 1);
        ans = s.substr(eq + 1);

        for (int i = c(x) || c(y) || c(ans); i <= 9; i++) {
            if (assignX(x, i) + assignX(y, i) == assignX(ans, i)) {
                pos = i;
                break;
            }
        }
        cout << ((pos < 0) ? "NA" : to_string(pos)) << endl;
    }

    return 0;
}

