#include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>
#include<algorithm>
using namespace std;

string intplus(string a,string b){
  if(a.size()<b.size())swap(a,b);
  int ai=a.size()-1,bi=b.size()-1,bii,k=0;
  string c = a;
  for(;ai>=0;ai--,bi--){
    bii = bi>=0?b[bi]:48;
    c[ai] = (a[ai]+bii+k-96)%10+48;
    if((a[ai]+bii+k-96)>=10)k=1;
    else k=0;
  }
  if(k==1)c="1"+c;
  return c;
}

int main(){
  string a,b,c,d,f,ff,n;
  while(cin>>f){
    bool chk = false;
    for(int i=0;i<10;i++){
      ff = f;
      n = " ";
      n[0] = (char)(i+48);
      while(ff.find("X")!=-1)ff.replace(ff.find("X"),1,n);
      a = ff.substr(0,ff.find("+"));
      b = ff.substr(ff.find("+")+1,ff.find("=")-ff.find("+")-1);
      c = ff.substr(ff.find("=")+1);
      if(i==0&&((a.size()>1&&a[0]=='0')||(b.size()>1&&b[0]=='0')||(c.size()>1&&c[0]=='0'))) continue;
      //cout<<intplus(a,b)<<endl;
      if(intplus(a,b)==c){
	cout<<i<<endl;
	chk = true;
      break;
      }
    }
    if(!chk)cout<<"NA"<<endl;
  }
  return 0;
}