#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#include <iterator>
#include <sstream>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

struct BigInt {
    vector<int> data;

    BigInt() : data(130, 0) { }

    BigInt(const string& s) : data(130, 0) { 
        for(int i = (int)s.length() - 1; i >= 0; i--) {
            int value = s[s.length() - 1 - i] - '0';
            data[i] = value;
        }
    }

    void dump() {
        ostringstream oss;
        oss << '[';
        for(int i = (int)data.size() - 1; i >= 0; i--) {
            oss << data[i];
            if(i != 0) oss << ' ';
        }
        oss << ']';
        cerr << oss.str() << endl;
    }

    BigInt operator +(const BigInt& x) {
        BigInt result;
        for(int i = 0; i < 125; i++) {
            result.data[i] += data[i] + x.data[i];
            result.data[i + 1] += result.data[i] / 10;
            result.data[i] %= 10;
        }
        return result;
    }

    bool operator ==(const BigInt& x) {
        return data == x.data;
    }
};

int main() {
    for(string line; getline(cin, line); ) {
        int plusPos = line.find('+');
        int equalPos = line.find('=');
        string l1s = line.substr(0, plusPos);
        string l2s = line.substr(plusPos + 1, equalPos - plusPos - 1);
        string rs = line.substr(equalPos + 1);
        int ans = -1;
        for(int num = 0; num <= 9; num++) {
            string l1s_ = l1s, l2s_ = l2s, rs_ = rs;
            replace(begin(l1s_), end(l1s_), 'X', (char)('0' + num));
            replace(begin(l2s_), end(l2s_), 'X', (char)('0' + num));
            replace(begin(rs_), end(rs_), 'X', (char)('0' + num));
            if(BigInt(l1s_) + BigInt(l2s_) == BigInt(rs_)) ans = num;
        }
        if(ans == -1) cout << "NA" << endl;
        else cout << ans << endl;
    }
}