#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return b.second > a.second;
    }
    return a.first < b.first;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    string s;
    while (cin >> s)
    {
        string exp1, exp2, exp3;
        int idx = 0;
        for (int i = 0; i < s.size(); ++i)
        {
            if (s[i] == '+')
            {
                exp1 = s.substr(0, i);
                idx = i;
            }
            else if (s[i] == '=')
            {
                exp2 = s.substr(idx + 1, i - idx - 1);
                exp3 = s.substr(i + 1, s.size() - i - 1);
            }
        }

        int n = exp1.size();
        int m = exp2.size();
        int l = exp3.size();

        //cout << n << " " << m << " " << l << endl;
        bool al = false;
        for (int t = 0; t <= 9; ++t)
        {
            bool f = true;

            int carry = 0;

            string t1 = exp1, t2 = exp2, t3 = exp3;

            for (int i = 0; i < n; ++i)
            {
                if (t1[i] == 'X')
                {
                    t1[i] = (char)(t + '0');
                }
            }
            for (int i = 0; i < m; ++i)
            {
                if (t2[i] == 'X')
                {
                    t2[i] = (char)(t + '0');
                }
            }
            for (int i = 0; i < l; ++i)
            {
                if (t3[i] == 'X')
                {
                    t3[i] = (char)(t + '0');
                }
            }
            int i = 0, j = 0, k = 0;

            //cout << t1 << " " << t2 << " " << t3 << endl;
            string waaaa = "";
            while (i < n || j < m)
            {
                int a, b;

                if (i < n)
                {
                    a = t1[n - i - 1] - '0';
                }
                else
                {
                    a = 0;
                }

                if (j < m)
                {
                    b = t2[m - j - 1] - '0';
                }
                else
                {
                    b = 0;
                }

                int sum = (a + b + carry) % 10;
                waaaa += (char)(sum + '0');

                carry = (a + b + carry) / 10;
                i++;
                j++;
            }

            if (carry)
                waaaa += (char)(carry + '0');

            reverse(waaaa.begin(), waaaa.end());

            //cout << waaaa << " " << t3 << endl;
            if (waaaa == t3)
            {
                cout << t << endl;
                al = true;
                break;
            }
        }
        if (!al)
        {
            cout << "NA" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3240