#include <bits/stdc++.h>
using namespace std;

int main() {
    string str;
    while (cin >> str) {
        int ans = -1;
        for (int i = 0; i < 10; i++) {
            string tmp = str;
            for (auto& j : tmp) if (j == 'X') j = '0' + i;
            stringstream ss;
            ss << tmp;
            int a, b, c;
            char s;
            ss >> a >> s >> b >> s >> c;
            if (a + b == c) {
                ans = i;
                break;
            }
        }
        if (ans < 0) cout << "NA" << endl;
        else cout << ans << endl;
    }

    return 0;
}