#include <iostream>

using namespace std;

int main()
{
    string s;

    while (cin >> s) {
        string a, b, c;

        a = s.substr(0, s.find("+"));
        b = s.substr(s.find("+") + 1, s.find("=") - s.find("+") - 1);
        c = s.substr(s.find("=") + 1, s.size() - s.find("=") - 1);

        bool flag = false;
        for (int x = 0; x < 10; x++) {
            if (x == 0 && (a[0] == 'X' || b[0] == 'X' || c[0] == 'X'))
                continue;
            
            int na = 0, nb = 0, nc = 0;
            for (int i = 0; i < a.size(); i++) {
                na *= 10;
                if (a[i] == 'X')
                    na += x;
                else
                    na += a[i] - '0';
            }
            for (int i = 0; i < b.size(); i++) {
                nb *= 10;
                if (b[i] == 'X')
                    nb += x;
                else
                    nb += b[i] - '0';
            }
            for (int i = 0; i < c.size(); i++) {
                nc *= 10;
                if (c[i] == 'X')
                    nc += x;
                else
                    nc += c[i] - '0';
            }

            if (na + nb == nc) {
                flag = true;
                cout << x << endl;
                break;
            }
        }
        if (!flag)
            cout << "NA\n";
    }

    return 0;
}