
#include<stdio.h>
#include<string.h>
char str[128];
int main()
{
    while(scanf("%s",str) != -1)
    {
        int OR = 0,memi = 0,cstrlongs[3] = {0};
        char cstr[3][128] = {0};
        for(int i = 0; i < 128; 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++)
        {
            cstrlongs[i] = (int)strlen(cstr[i]);
        }
        for(int i = 0; i < 2; i++)
        {
            for(int j = cstrlongs[i] - 1; j >= 0; j--)
            {
                cstr[i][j + cstrlongs[2] - cstrlongs[i]] = cstr[i][j];
                if(cstrlongs[2] - cstrlongs[i] != 0)cstr[i][j] = '0';
            }
        }
        for(int i = 0; i < 11; i++)
        {
            char test[3][128] = {0};
            char mem[128] = {0};
            for(int j = cstrlongs[2] - 1; j >= 0; j--)
            {
                for(int k = 0; k < 3; k++)
                {
                    if(cstr[k][j] == 'X')test[k][j] = i + '0';
                    else test[k][j] = cstr[k][j];
                }
                mem[j] += (((test[0][j] - '0') + (test[1][j] - '0')) % 10) + '0';
                mem[j - 1] += ((test[0][j] - '0') + (test[1][j] - '0') + '0') / 58;
            }
            if(i == 10)
            {
                printf("NA\n");
                break;
            }
            if(strcmp(mem,test[2]) == 0)
            {
                printf("%d\n",i);
                break;
            }
        }
    }
}