#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
bool check(string str){
    int p=str.find('+');
    int e=str.find('=');
    stringstream ss;
    string s[3];
    s[0]=str.substr(0,p);
    s[1]=str.substr(p+1,e-p-1);
    s[2]=str.substr(e+1,str.length()-e-1);
    if(s[0][0]=='0'||s[1][0]=='0'||s[2][0]=='0')return false;
    int ma=max(s[0].length(),max(s[1].length(),s[2].length()));
    for(int i=0;i<3;i++)reverse(s[i].begin(),s[i].end());
    for(int i=0;i<3;i++){
        for(int j=s[i].length();j<=ma;j++)s[i]+='0';
    }
    int up=0;
    for(int i=0;i<=ma;i++){
        int v1=s[0][i]-'0',v2=s[1][i]-'0',v3=s[2][i]-'0';
        int val=v1+v2+up;
        if(val%10!=v3)return false;
        if(val>9)up=1;
        else up=0;
    }
    return true;
}
int main(){
    string str;
    while(cin>>str){
        int ans=-1;
        for(int i=0;i<=9;i++){
            string s=str;
            while(true){
                if(s.find('X')==string::npos)break;
                s[s.find('X')]=i+'0';
            }
            if(check(s)){
                ans=i;
                break;
            }
        }
        if(ans==-1)cout<<"NA"<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}