#include<iostream>
#include<string>
#include<sstream>
#include<cstdlib>
using namespace std;
int main(){
  string a,b,c,f,ff,n;
  stringstream ss;
  int aa,bb,cc;
  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[0]=='0'||b[0]=='0'||c[0]=='0')) continue;
      aa = atoi(a.c_str());
      bb = atoi(b.c_str());
      cc = atoi(c.c_str());
      if(aa+bb==cc){
	cout<<i<<endl;
	chk = true;
	break;
      }
    }
    if(!chk)cout<<"NA"<<endl;
  }
  return 0;
}