#include <bits/stdc++.h>
using namespace std;
 
long long toLong(string str, int n)
{
    long long res = 0;
    for (int i = 0; i < str.size(); i++){
        if (str[i] != 'X'){
            res = res * 10 + str[i] - '0';
        }
        else {
            res = res * 10 + n;
        }
    }
    return res;
}
 
int main()
{
    //char A[128], B[128], C[128];
    while (true){
        string str[3];
        string line;
        if (!(cin >> line)) return 0;
         
        for (int p = 0, i = 0; p < line.size(); p++){
            if (line[p] != '+' && line[p] != '='){
                str[i] += line[p];
            }
            else {
                i++;
            }
        }
         
        int res = -1;
        for (int i = 0; i <= 9; i++){
            if (toLong(str[0], i) + toLong(str[1], i) - toLong(str[2], i) == 0LL){
                res = i;
            }
        }
         
        if (res != -1) printf("%d\n", res);
        else puts("NA");
    }
     
    return 0;
}