#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int i,a,b,c;
  string s;
  while(cin>>s){
    bool f = false;
    for(int j = i = 0 ; j < 10 ; j ++){
      if(s[i] == 'X' && j == 0)continue;
      for(i=a=0;s[i]!= '+';i++)a = a * 10 + (s[i] == 'X' ? j : s[i] - '0');i++;
      if(s[i] == 'X' && j == 0)continue;
      for(b=0;s[i]!= '=';i++)b = b * 10 + (s[i] == 'X' ? j : s[i] - '0');i++;
      if(s[i] == 'X' && j == 0)continue;
      for(c=0;s[i]!='\0';i++)c = c * 10 + (s[i] == 'X' ? j : s[i] - '0');
      if(a+b==c){
        cout<<j<<endl;
        f = true;
        break;
      }
    }
    if(!f)cout<<"NA"<<endl;
  }
}