#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int number(string const& s, int i, int& p) {
    int res = 0;
    while(p < s.size() && (isdigit(s[p]) || s[p] == 'X')) {
        res *= 10;
        if(s[p] == 'X') {
            res += i;
        } else {
            res += s[p] - '0';
        }
        p++;
    }
    return res;
}

int main() {
    string s;
    while(cin >> s) {
        bool leading = s[0] == 'X' && s[1] != '+'
                       || s[s.find('+')+1] == 'X' && s[s.find('+')+2] != '='
                       || s[s.find('=')+1] == 'X' && s.find('=') != s.size()-2;
        int p = 0, n1 = 0, n2 = 0;
        int res = -1;
        for(int i=leading; i<10; ++i) {
            p = 0;
            int n1 = number(s, i, p);
            int n2 = number(s, i, ++p);
            int n3 = number(s, i, ++p);
            if(n1 + n2 == n3) {
                res = i;
                break;
            }
        }
        if(res == -1) {
            cout << "NA" << endl;
        } else {
            cout << res << endl;
        }
    }
}
