#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    string str;
    while(getline(cin, str)) {
        int i = 0;
        for(i = 0; i < 10; i++) {
            string test = str;
            for(int c = 0; c < str.length(); c++) {
                if(test[c] == 'X') {
                    test[c] = '0' + i;
                }
            }
            if ( i == 0 ) {
                bool pass = false;
                for(int c = 0; c < str.length(); c++) {
                    if (c == 0 && test[0] == '0' && test[1] != '+') {
                        pass = true;
                    } else if (test[c] == '+' && test[c+1] == '0' && test[c+2] != '=') {
                        pass = true;
                    } else if (test[c] == '=' && test[c+1] == '0' && c + 2 != str.length()) {
                        pass = true;
                    }
                }
                if (pass) {
                    continue;
                }
            }
            stringstream is;
            is << test;
            int a, b, c;
            char d;
            is >> a >> d >> b >> d >> c;
            if (a + b == c) {
                cout << i << endl;
                break;
            }
        }
        if(i == 10) {
            cout << "NA" << endl;
        }
    }
     
    return 0;
}