#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;
  int i;
  while(cin>>s){
    rep(i,10){
      int j=0;
      int a=0,b=0,c=0;//a+b=c
      int co=0;
      while(s[j]!='+'){
	a*=10;
	if(s[j]=='X')a+=i;
	else a+=s[j]-'0';
	j++;
	co++;
	//cout<<a<<endl;
      }
      if(co>=2&&pow(10,co-1)-a>0)continue;
      j++;
      co=0;

      while(s[j]!='='){
	b*=10;
	if(s[j]=='X')b+=i;
	else b+=s[j]-'0';
	j++;
	co++;
	//cout<<b<<endl;
      }
      if(co>=2&&pow(10,co-1)-b>0)continue;
      j++;
      co=0;

      while(j!=s.size()){
	c*=10;
	if(s[j]=='X')c+=i;
	else c+=s[j]-'0';
	j++;
	co++;
      }
      if(co>=2&&pow(10,co-1)-c>0)continue;
      
      if(a+b==c)break;
    }
    if(i==10)cout<<"NA"<<endl;
    else cout<<i<<endl;
  }
}