#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main() {
    string a, b, c;
    string str;
    int i, j, k;

    while (cin >> str) {
        if(cin.eof()) break;

        for (i=0; str[i]!='+'; i++);
        a = str.substr(0, i);
        for (j=0; str[j+i+1]!='='; j++);
        b = str.substr(i+1, j);
        c = str.substr(j+i+2, str.length()-j+i-1);

        for (i=0; i<10; i++) {
            string a1 = a, b1 = b, c1 = c;
            
            if(i == 0) {
                if(a1.length() > 1) {
                    if(a1[0] == 'X') {
                        i++;
                        continue;
                    }
                }
                if(b1.length() > 1) {
                    if(b1[0] == 'X') {
                        i++;
                        continue;
                    }
                }
                if(c1.length() > 1) {
                    if(c1[0] == 'X') {
                        i++;
                        continue;
                    }
                }
            }

            for (j=0; j<a1.length(); j++) {
                if(a1[j] == 'X') a1[j] = i+'0';
            }
            for (j=0; j<b1.length(); j++) {
                if(b1[j] == 'X') b1[j] = i+'0';
            }
            for (j=0; j<c1.length(); j++) {
                if(c1[j] == 'X') c1[j] = i+'0';
            }

            if(atoi(a1.c_str())+atoi(b1.c_str()) == atoi(c1.c_str())) {
                cout << i << endl;
                break;
            }

            if(i == 9) cout << "NA" << endl;
        }
    }
}