#include <iostream>
#include <cctype>
using namespace std;

int main(){
    string expr;
    while( cin>>expr ){
        long long int n[3] = {0, 0, 0}, x[3] = {0, 0, 0};
        string::iterator it = expr.begin();
        int i = 0;
        while( true ){
            n[i] *= 10; x[i] *= 10;
            if( isdigit(*it) ) n[i] += *it-'0';
            if( *it == 'X' ) x[i] += 1;
            it++;
            if( it == expr.end() ) break;
            if( *it == '+' || *it == '=' ){
                it++; i++;
            }
        }
        int b = 0;
        for(i = 0; i < 3; i++){
            if( x[i]>=10 && x[i]>n[i] ) b = 1;
        }
        for(i = b; i < 10; i++){
            if( n[0]+n[1]-n[2]+(x[0]+x[1]-x[2])*i == 0 ){
                cout << i << endl;
                break;
            }
        }
        if( i == 10 ) cout << "NA" << endl;
    }
    return 0;
}