#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin >>s){
    bool f = false;
    for(int i=0; i<10; i++){
      string s_dush;
      s_dush = s;
      for(int j=0; j<s.size(); j++){
	if(s[j] == 'X'){s_dush[j] = i+'0';}
	else{s_dush[j] = s[j];}
      }
      long long value[3] = {0}, ax = 0;
      for(int j=0; j<s_dush.size(); j++){
	if(isdigit(s_dush[j])){value[ax] = value[ax]*10 + s_dush[j]-'0';}
	else{ax++;}
      }
      if(value[0]+value[1] == value[2]){cout <<i<<endl;f = true;break;}
    }
    if(!f){cout <<"NA"<<endl;}
  }
  return 0;
}