#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        if(!(cin >> s))
            return 0;

        bool notZero = false;
        if(s[0] == 'X' && s[1] != '+')
            notZero = true;
        int j = s.find('+');
        if(s[j+1] == 'X' && s[j+2] != '=')
            notZero = true;
        j = s.find('=');
        if(s[j+1] == 'X' && j != s.size()-2)
            notZero = true;

        bool na = true;
        for(int i=0; i<=9; ++i){
            if(i == 0 && notZero)
                continue;
            string s1 = s;
            replace(s1.begin(), s1.end(), 'X', (char)('0'+i));
            istringstream iss(s1);
            int x, y, z;
            char c;
            iss >> x >> c >> y >> c >> z;
            if(x + y == z){
                cout << i << endl;
                na = false;
                break;
            }
        }

        if(na)
            cout << "NA" << endl;
    }
}