#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) cout << (x) << endl
#define ENDL cout << endl
#define EPS (1e-8)
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T& a, T b){if(a>b){a=b; return true;} return false;}
template <class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;} return false;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

signed main(){
    string s;
    while(cin >> s){
        string t1 , t2 , t3;
        int i = 0;
        while(s[i]!='+'){
            t1 += s[i++];
        }
        ++i;
        while(s[i]!='='){
            t2 += s[i++];
        }
        ++i;
        while(s[i]!=0){
            t3 += s[i++];
        }
        string s1 = t1;
        string s2 = t2;
        string s3 = t3;
        bool ans = false;
        for( i = 0; i < 10 ; ++i){
            t1 = s1; t2 = s2; t3 = s3;        
            rep(j , t1.size()){
                if(t1[j]=='X') t1[j]='0'+i;
            }
            rep(j , t2.size()){
                if(t2[j]=='X') t2[j]='0'+i;
            }
            rep(j , t3.size()){
                if(t3[j]=='X') t3[j]='0'+i;
            }
            if(t1.size() < t2.size()) swap(t1 , t2);
            for(int i = t1.size()-1 , j =t2.size()-1 ; i >=0 ; --i , --j){
                if( j >= 0 ) t1[i] += t2[j] - '0';
                    if(t1[i] > '9') {
                        t1[i]-=10;
                        if(i == 0) t1 = '1' + t1;
                        else ++t1[i-1];
                }
            }
            
            if( t1 == t3  ) { ans = true; break; }
        }
        if( ans ) cout << i << endl;
        else cout << "NA" << endl;
    }
}
