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


int main(){
    string expr;
    while( cin >> expr ){
        vector<int> v(3, 0);
        vector<int> Xm(3, 0);
        int head = 0;
        int i = 0;
        for(string::iterator it = expr.begin(); it != expr.end(); it++){
            if( *it == '+' || *it == '=' ) i++;
            Xm[i] *= 10;
            v[i] *= 10;
            if( isdigit( *it ) ){
                v[i] += *it - '0';
            }
            if( *it == 'X' ){
                if( Xm[i] == 0 && v[i] == 0 ) head = 1;
                Xm[i]++;
            }
        }
        bool found = false;
        //cout << v[0] << ' ' << v[1] << ' ' << v[2] << endl;
        //cout << Xm[0] << ' ' << Xm[1] << ' ' << Xm[2] << endl;
        for(int i = head; i <= 9 && !found; i++){
            if( v[0] + v[1] + Xm[0]*i + Xm[1]*i == v[2] + Xm[2]*i ){
                cout << i << endl;
                found = true;
            }
        }
        if( !found ) cout << "NA" << endl;
    }
    return 0;
}