#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
  string s;
  int ans;
  while(cin>>s){
    ans=-1;
    for(int i=0;i<10;i++){
      string t=s;
      while(t.find("X")!=string::npos)t[t.find("X")]='0'+i;
      string a,b,c;
      a=t.substr(0,t.find("+"));
      b=t.substr(t.find("+")+1,t.find("=")-t.find("+")-1);
      c=t.substr(t.find("=")+1,t.size()-t.find("=")-1);
      if(a[0]=='0' || b[0]=='0' || c[0]=='0')continue;
      if(atoi(a.c_str())+atoi(b.c_str())==atoi(c.c_str()))ans=i;
    }
    if(ans==-1)puts("NA");
    else cout<<ans<<endl;
  }
}