#include <iostream>
#include <sstream>
#include <iostream>
#include <stdlib.h>

using namespace std;

string m_replace(string str, string replaced) {
    string::size_type find = 0;

    while ((find = str.find('X', find)) != string::npos) {
        str.replace(find, replaced.size(), replaced);
    }

    return str;
}

void cal(string& op1, string& op2, string& ans) {
    stringstream ss;

    for (int i = 0; i <= 9; i++) {
        int n, m, a;

        ss << i;
        const string is = ss.str();

        n = atoi(m_replace(op1, is).c_str());
        m = atoi(m_replace(op2, is).c_str());
        a = atoi(m_replace(ans, is).c_str());

        if (n + m == a) {
           std::cout << i << std::endl;
           return;
        }

        // sstream clear
        ss.str("");
    }

    std::cout << "NA" << std::endl;
}


int main(void) {

    while (std::cin) {
        string exp;
        getline(cin, exp);

        if (exp.size() <= 1) {
            break;
        }

        string::size_type t, u;
        t = u = exp.find_first_of('+', 0);

        string op1(exp, 0, u);
        u = exp.find_first_of('=', t);

        string op2(exp, t + 1, u - t - 1);
        string ans(exp, u + 1, exp.size());

        cal(op1, op2, ans);
    }

    return 0;
}