#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

void Solution();

int main()
{
    Solution();
    return 0;
}

void Solution()
{
    string s,devideStr;
    
    while(cin>>s)
    {
        devideStr = s;
        
        bool flag = true;
        
        for(int i = 0; i < 10; i++)
        {
            for(int j = 0; j < (int)s.size(); j++)
            {
                if(s[j] == 'X') // the number which we want to get
                {
                    devideStr[j] = i+'0'; //give the string data to array
                }
                else
                {
                    devideStr[j] = s[j];
                }
            }
            
            string a,b,c,d;
            
            int addOperator = devideStr.find('+');
            int equOperator = devideStr.find('=');
            
            a = devideStr.substr(0,addOperator); /// the first number in the equation
            b = devideStr.substr(addOperator + 1, equOperator - addOperator - 1); // the second number
            c = devideStr.substr(equOperator + 1, devideStr.size());
            
            int as = a.size(), bs = b.size();
            int alls = max(as,bs);
            
            int x = 0;
            
            for(int j = 0; j < alls; j++)
            {
                if(j < as && j < bs)
                {
                    x += a[as - j - 1] + b[bs - j - 1] - '0' * 2;
                }
                else if(j < as)
                {
                    x += a[as - j - 1] - '0';
                }
                else if(j < bs)
                {
                    x += b[bs - j - 1] - '0';
                }
                
                d = (char)(x % 10 + '0') + d;
                x /= 10;
            }
            
            if(x)
            {
                d = (char)(x%10+'0')+d;
            }
            
            if(d == c)
            {
                cout <<i<<endl;
                
                flag = false;
                break;
            }
        }
        
        if(flag)
        {
            cout <<"NA"<<endl;
        }
    }
}