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

bool eval(string s) {
    int a = 0, b = 0, c = 0, i;
    for (i=0; s[i]!='+'; ++i) {
        a = a * 10 + (s[i] - '0');
    }
    i ++;
    for (; s[i]!='='; ++i) {
        b = b * 10 + (s[i] - '0');
    }
    i ++;
    for (; i<(int)s.size(); ++i) {
        c = c * 10 + (s[i] - '0');
    }
    stringstream ss;
    ss << a << "+" << b << "=" << c;
    return a + b == c && s == ss.str();
}

int main() {
    string s;
    while (cin >> s) {
        int ans = -1;
        for (int c=0; c<=9; ++c) {
            string t = s;
            for (int i=0; i<(int)t.size(); ++i) {
                if (t[i] == 'X') t[i] = char(c + '0');
            }
            if (eval(t)) {
                ans = c;
                break;
            }
        }
        if (ans == -1) {
            cout << "NA" << endl;
        } else {
            cout << ans << endl;
        }
    }
    return 0;
}