#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  while(cin>>s){
    int j,i;
    rep(j,10){
      vector<int>a,b,c;//a+b=c
      int i=0;
      while(s[i]!='+'){
	if(s[i]!='X')a.pb(s[i]-'0');
	else a.pb(j);
	i++;
      }
      i++;
      while(s[i]!='='){
	if(s[i]!='X')b.pb(s[i]-'0');
	else b.pb(j);
	i++;
      }
      i++;
      while(i!=s.size()){
	if(s[i]!='X')c.pb(s[i]-'0');
	else c.pb(j);
	i++;
      }
      if(!a[0]||!b[0]||!c[0])continue;
      reverse(all(a));
      reverse(all(b));
      reverse(all(c));
      int m=max(a.size(),b.size());
      vector<int>d(m+1,0);
      for(int i=m-a.size();m!=a.size();)a.pb(0);
      for(int i=m-b.size();m!=b.size();)b.pb(0);
      int h=0;
      rep(i,m){
	d[i]+=(a[i]+b[i]+h)%10;
	if(a[i]+b[i]+h>=10)h=1;
	else h=0;
      }
      d[d.size()-1]=h;
      if(!d[d.size()-1])d.pop_back();
      /*
      rep(i,a.size())cout<<a[i];
      cout<<endl;
      rep(i,b.size())cout<<b[i];
      cout<<endl;
      rep(i,c.size())cout<<c[i];
      cout<<endl;
      rep(i,d.size())cout<<d[i];
      cout<<endl;
      */
      if(d==c)break;
    }
    if(j==10)cout<<"NA"<<endl;
    else cout<<j<<endl;
  }
}