#include<stdio.h>
#include<iostream>
#include<string.h>

using namespace std;
char str[100],cstr[3][100];
int OR,memi;
int strlong;
int test[3][10];
int bikkuri(int n)
{
    if(n == 0)return 1;
    return 10 * bikkuri(n - 1);
}

int main()
{
    while(scanf("%s",str) != -1)
    {
        OR = 0;memi = 0;
        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < 100; j++)
            {
                cstr[i][j] = 0;
            }
        }
        for(int i = 0; i < 1000; i++)
        {
            if(str[i] == '\0')break;
            if(str[i] == '+'||str[i] == '=')
            {
                OR++;memi = i + 1;
            }
            else cstr[OR][i - memi] = str[i];
        }
        for(int i = 0; i < 3; i++)// a b ans
        {
            strlong = (int)strlen(cstr[i]);
            for(int j = 0; j < 10; j++)// X
            {
                test[i][j] = 0;
                for(int k = 0; k < strlong; k++) // test
                {
                    if(cstr[i][k] != 'X')test[i][j] += (bikkuri(strlong - k) * (cstr[i][k] - '0')) / 10;
                    else test[i][j] += (bikkuri(strlong - k) * j) / 10;
                }
            }
        }
        for(int i = 0; i < 11; i++)
        {
            if(i == 10)
            {
                printf("NA\n");
                break;
            }
            if(test[0][i] + test[1][i] == test[2][i])
            {
                printf("%d\n",i);
                break;
            }
        }
    }
}