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

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

    for(int i=0; i<3; ++i) reverse(par[i].begin(), par[i].end());

    string res = "";
    int carry = 0;
    for(int i=0; i<min(par[0].length(), par[1].length()); ++i) {
        int k = par[0][i] - '0',l = par[1][i] - '0';
        carry += k + l;
        res += string(1, (carry%10)+'0');
        carry /= 10;
    }
    int ll = (par[0].length() < par[1].length());
    for(int i=min(par[0].length(), par[1].length());
        i < max(par[0].length(), par[1].length()); ++i) {
        carry += par[ll][i] - '0';
        res += string(1, (carry%10)+'0');
        carry /= 10;
    }
    if(carry > 0) res += string(1, carry+'0');
    return res == 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:;
    }
}