#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main(){
    int a[3];
    string line,s1;
    while(cin >> line){
        bool ju = false;
        for(int n=0;n<10;n++){
            int len = 0;
            s1 = "";
            for(int i=0;i<line.size();i++){
                if(line[i] == '+' || line[i] == '='){
                    a[len] = atoi(s1.c_str()); len++;
                    s1 = "";
                }
                else if(line[i] == 'X') s1 += n+'0';
                else s1 += line[i];
            }
            a[2] = atoi(s1.c_str());
            if(a[0] + a[1] == a[2]){
                cout << n << endl; ju = true; break;
            }
        }
        if(!ju) cout << "NA" << endl;
    }
}