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

using namespace std;

int myatoi(string str);

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') {
                        continue;
                    }
                }
                if(b1.length() > 1) {
                    if(b1[0] == 'X') {
                        continue;
                    }
                }
                if(c1.length() > 1) {
                    if(c1[0] == 'X') {
                        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';
            }

            //cout << a1 << b1 << c1 << endl;
            //cout << myatoi(a1) << myatoi(b1) << myatoi(c1) <<  endl;

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

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

int myatoi(string str) {
    int res = 0;

    for (int i=0; i<str.length(); i++) {
        int a = str[i] - '0';
        res += a * (int)(pow(10, str.length()-i-1)+0.5);
    }

    return res;
}