#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int solve(char n,string upper,string under,string ans){
    while(upper.find("X")!=string::npos) upper.replace(upper.find("X"),1,&n);
    while(under.find("X")!=string::npos) under.replace(under.find("X"),1,&n);
    while(ans.find("X")!=string::npos) ans.replace(ans.find("X"),1,&n);
    for(int i=upper.size()-1,j=under.size()-1;i>=0;i--,j--){
        if(j>=0) upper[i] += under[j]-'0';
        if(upper[i] > '9'){
            upper[i] -= 10;
            if(i == 0) upper = "1" + upper;
            else upper[i-1]++;
        }
    }
    return (upper == ans)? 1 : 2;
}

int main(){
    string line,s1,s2,s3;
    while(cin >> line){
        bool judge = false;
        s1 = line.substr(0,line.find('+'));
        s2 = line.substr(line.find('+')+1,line.find('=')-(line.find('+')+1));
        s3 = line.substr(line.find('=')+1);
        if(s1.size() < s2.size()) swap(s1,s2);
        for(int i=0;i<10;i++){
            char ss = i +'0';
            if(solve(ss,s1,s2,s3) == 1){
                cout << i << endl;
                judge = true;
                break;
            }
        }
        if(!judge) cout << "NA" << endl;
    }
}