#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

string f(string s,string t){
    string res;
    if(s.size()>t.size()) swap(s,t);
    int sn = s.size(), tn = t.size();
    reverse(s.begin(),s.end()), reverse(t.begin(),t.end());
    int x, y, z = 0;
    rep(i,sn){
        x = s[i] - '0', y = t[i] - '0';
        if(x+y+z<=9){ 
            res += (x + y + z + '0');
            z = 0;
        }else{
            res += (x + y + z) % 10 + '0';
            z = 1;
        }
    }
    if(tn == sn && z == 1) res += '1';
    else if( tn != sn){
        t = t.substr(sn);
        rep(i,tn-sn){
            int x = t[i] + z - '0';
            if(x<=9){ 
                res += x + '0';
                z = 0;
            }else{
                res += x%10 + '0';
                z = 1;
            }
        }
        if(z) res += '1';
    }

    reverse(res.begin(),res.end());
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
/*
    string s,t;
    cin >> s >> t;
    cout << f(s,t) << endl;
*/


    string eq;
	while(cin >> eq){
        if(eq == "") break;

        string x1;
        bool flag = true;
        int i = 0;
        vector<int> y1;
        while(flag){
            if(eq[i] == 'X') y1.push_back(i);
            if(eq[i] != '+'){ x1 += eq[i]; i++; }
            else flag = false;
        }

        string x2;
        i++;
        eq = eq.substr(i);
        flag = true; i = 0;
        vector<int> y2;
        while(flag){
            if(eq[i] == 'X') y2.push_back(i);
            if(eq[i] != '='){ x2 += eq[i]; i++; }
            else flag = false; 
        }

        i++;
        string x3 = eq.substr(i);
        vector<int> y3;
        rep( i, x3.size() ) if(x3[i] == 'X') y3.push_back(i);

        int ans = -1;
        rep(i,10){
            string z1 = x1, z2 = x2, z3 = x3;
            rep(j,y1.size()) z1.replace(y1[j],1,to_string(i));
            rep(j,y2.size()) z2.replace(y2[j],1,to_string(i));
            rep(j,y3.size()) z3.replace(y3[j],1,to_string(i));

            if(f(z1,z2) == z3) ans = i;
        }
        if(ans < 0) cout << "NA" << endl;
        else cout << ans << endl;

    }


    return 0;
}
