#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int i;
  string s,a,b,c;
  while(cin>>s){
    bool f = false;
    for(int j = i = 0 ; j < 10 ; j ++){
      i = 0;
      for(a="";s[i]!='+';i++)a+=(s[i]=='X'?j+'0':s[i]);i ++;
      for(b="";s[i]!='=';i++)b+=(s[i]=='X'?j+'0':s[i]);i ++;
      for(c="";s[i]!='\0';i++)c+=(s[i]=='X'?j+'0':s[i]);

      if(a[0] == '0' || b[0] == '0' || c[0] == '0')continue;
      if(stoi(a) + stoi(b) == stoi(c)){
        cout<<j<<endl;
        f = true;
        break;
      }
//      cout<<a<<" "<<b<<" "<<c<<endl;
    }
    if(!f)cout<<"NA"<<endl;
  }
}