#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string hissan(string a, string b) {
    if (a.size() < b.size()) a.swap(b);
    int bi = b.size() - 1;
    int c = 0;
    string ans;

    for (int i = a.size() - 1 ; i >= 0; i--) {
        int _a = a[i] - '0';
        int _b = (bi >= 0) ? b[bi--] - '0' : 0;
        int x = _a + _b + c;

        if (x < 10) {
            c = 0;
        } else {
            x -= 10;
            c = 1;
        }
        ans.insert(0, to_string(x));
    }
    if (c) ans.insert(0, "1");

    return ans;
}

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

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++) {
            string _x   = replaceX(x, i);
            string _y   = replaceX(y, i);
            string _ans = replaceX(ans, i);
            // cout << _x << " + " << _y << " = " << _ans << endl;
            if (hissan(_x, _y) == _ans) {
                pos = i;
                break;
            }
        }
        cout << ((pos < 0) ? "NA" : to_string(pos)) << endl;
    }

    return 0;
}

