#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

vector<string> split(const string &str, char delim) {
    vector<string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != string::npos) {
        res.push_back(string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(string(str, current, str.size() - current));
    return res;
}

int main() {
    string s;
    while(cin >> s) {
        vector<string> t = split(s,'+');
        vector<string> v = split(t[1], '=');

        string a = t[0], b = v[0] , c = v[1];
        bool flag = true;

        int len = 0;
        len = max(len,(int)a.size());
        len = max(len,(int)b.size());
        len = max(len,(int)c.size());

        REP(i,a.size(),len) {
            a = "0" + a;
        }
        REP(i,b.size(),len) {
            b = "0" + b;
        }
        REP(i,c.size(),len) {
            c = "0" + c;
        }

        rep(i,10) {
            char ch = '0' + i;
            string A = a, B = b, C = c;

            rep(j,a.size()) {
                if(a[j] == 'X') A[j] = ch;
            }
            rep(j,b.size()) {
                if(b[j] == 'X') B[j] = ch;
            }
            rep(j,c.size()) {
                if(c[j] == 'X') C[j] = ch;
            }

            int res = 0;
            int d = 1;
            int carry = 0;

            for(int j=a.size()-1; j>=0 ; j--) {
                int s = A[j] - '0';
                int t = B[j] - '0';

                s += t + carry;
                carry = s / 10;
                s %= 10;
                s *= d;

                res += s;
                d *= 10;
            }

            stringstream ss;
            ss << res;

            if(ss.str() == C) {
                flag = false;
                cout << i << endl;
            }
        }

        if(flag) cout << "NA" << endl;

    }
    return 0;
}