#include <string>
#include <iostream>

int strtoint(std::string str,int x){
  for(int i=0;i<str.length();++i){
    if(str[i]=='X')str[i]=x+'0';
  }
  return std::stoi(str);
}
int main(){
  std::string str;
  while(std::cin>>str){
    std::string str1,str2,str3;
    int i=0;
    for(;str[i]!='+';++i){
      str1.push_back(str[i]);
    }
    i++;
    for(;str[i]!='=';++i){
      str2.push_back(str[i]);
    }
    i++;
    for(;i<str.length();++i){
      str3.push_back(str[i]);
    }
    bool isfound=false;
    for(int x=0;x<=9;++x){
      if(strtoint(str1,x)+strtoint(str2,x)==strtoint(str3,x)){
        std::cout<<x<<std::endl;
        isfound=true;
        break;
      }
    }
    if(!isfound)std::cout<<"NA"<<std::endl;
  }
}