#include<iostream>
#include<string>
using namespace std;
int main(){
  string s,ss;
  while(cin >>s){
    ss = s;
    bool f = true;
    for(int i=0; i<10; i++){
      for(int j=0; j<s.size(); j++){
	if(s[j] == 'X'){ss[j] = i+'0';}
	else{ss[j] = s[j];}
      }
      string a,b,c,d;
      int pos_add = ss.find('+');
      int pos_equ = ss.find('=');
      a = ss.substr(0,pos_add);
      b = ss.substr(pos_add+1,pos_equ-pos_add-1);
      c = ss.substr(pos_equ+1,ss.size());
      int as = a.size(), bs = b.size();
      int alls = max(as,bs);
      int x = 0;
      for(int j=0; j<alls; j++){
	if(j<as && j<bs){x+=a[as-j-1]+b[bs-j-1]-'0'*2;}
	else if(j<as){x+=a[as-j-1]-'0';}
	else if(j<bs){x+=b[bs-j-1]-'0';}
	d = (char)(x%10+'0')+d;
	x/=10;
      }
      if(d == c){cout <<i<<endl;f = false;break;}
    }
    if(f){cout <<"NA"<<endl;}
  }
  return 0;
}