

#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

void replace( string &s, char src, char dst ) {
    replace( s.begin(), s.end(), src, dst ); 
}

bool check( string a, string b, string c ) {
    istringstream iss1( a );
    istringstream iss2( b );
    istringstream iss3( c );
    int A, B, C;
    iss1 >> A;
    iss2 >> B;
    iss3 >> C;
    return A + B == C;
}

void solve( string A, string B, string C ) {
    for ( char i = '0'; i <= '9'; ++ i ) {
        string a = A;
        string b = B;
        string c = C;
        replace( a, 'X', i );
        replace( b, 'X', i );
        replace( c, 'X', i );
        if ( check( a, b, c ) ) {
            cout << i << endl;
            return;
        }
    }
    cout << "NA" << endl;
}

int main() {
    string line;
    while ( cin >> line ) {
        replace( line, '+', ' ' );
        replace( line, '=', ' ' );
        istringstream iss( line );
        string a, b, c;
        iss >> a >> b >> c;
        solve( a, b, c );
    }
    return 0;
}