#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 ); 
}

void reverse( string &s ) {
    reverse( s.begin(), s.end() );
}

string add( string a, string b ) {
    reverse( a );
    reverse( b );
    if ( a.size() < b.size() ) swap( a, b );
    int n = min( a.size(), b.size() );
    a += '0';
    b += '0';
    for ( int i = 0; i < n; ++ i ) {
        int na = a[i] - '0';
        int nb = b[i] - '0';
        int nc = ( na + nb ) % 10;
        a[i] = nc + '0';
        if ( na + nb >= 10 ) {
            int t = i + 1;
            a[t] ++;
            while ( a[t] > '9' ) {
                a[t] = '0';
                t ++;
                a[t] ++;
            }
        }
    }
    reverse( a );
    
    int m = a.size();
    string t;
    bool f = false;
    for ( int i = 0; i < m; ++ i ) {
        if ( a[i] != '0' ) {
            f = true;
        }
        if ( f ) {
            t += a[i];
        }
    }
    return t;
}

bool check( string a, string b, string c ) {
    return add( a, b ) == c;
}

void solve( string A, string B, string C ) {
    for ( char i = '0'; i <= '9'; ++ i ) {
        if ( i == '0' ) {
            if ( A[0] == 'X' || B[0] == 'X' || C[0] == 'X' ) continue;
        }
        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;
}