#include<iostream>
using namespace std;

string str;
void so(int& i,int& r,int k,char c){
    while(str[i]!=c&&i!=str.length()){
        if(str[i]=='X')
            r=r*10+k;
        else
            r=r*10+str[i]-'0';
        i++;
    }i++;
}
int main(){
    while(cin>>str){
        int s=0,k=0;
        for(;k<10;k++){
            int a=0,b=0,c=0,i=0;
            so(i,a,k,'+');//cout<<"a: "<<a<<endl;
            so(i,b,k,'=');//cout<<b<<endl;
            so(i,c,k,'.');//cout<<c<<endl;
            if(a+b==c){cout<<k<<endl;s=1;break;}
        }
        if(!s)cout<<"NA"<<endl;
    }
}