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

bool isvalid(string s,int k) {
    long long par[3] = {},stat=0;
    for(int i=0; i<s.length(); ++i) {
        if(s[i] == '+') stat++;
        else if(s[i] == '=') stat++;
        else {
            par[stat] *= 10;
            if(s[i] == 'X') par[stat] += k;
            else par[stat] += s[i] - '0';
        }
    }
    return (par[0]+par[1] == par[2]);
}

int main() {
    string s;
    while(cin>>s) {
        for(int i=0; i<=9; ++i) {
            if(isvalid(s,i)) {
                cout<<i<<endl;
                goto NEXT;
            }
        }
        cout<<"NA"<<endl;
    NEXT:;
    }
}