#include <iostream>
#include <sstream>
#include <iostream>
#include <cstdlib>
#include <algorithm>

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++) {
        ss << i;
        const string is = ss.str();

        string n = m_replace(op1, is), m = m_replace(op2, is);
        string a = "";

        // short
        unsigned int n_size = n.size();
        // long
        unsigned int m_size = m.size();

        if (m_size < n_size) {
            swap(n, m);
            swap(n_size, m_size);

            while (n_size != m_size) {
                n.insert(0, "0");
                n_size = n.size();
            }
        }

        int c = 0;
        for (int j = n_size - 1; 0 <= j; --j) {
            // clear
            ss.str("");

            int n1 = n[j] - '0';
            int n2 = m[j] - '0';
            int add = (n1 + n2 + c);
            ss << (add % 10);
            c = add / 10;

            a.insert(0, ss.str());
        }

        if (a == m_replace(ans, is)) {
            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;
}