#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
namespace mp = boost::multiprecision;
using namespace std;
#define INF 0x7FFFFFFF



int main(){
  string s;
  cin >> s;
  mp::cpp_int f=0;
  while(s.size()){
    f=0;
    for(int i=0;i<10;i++){
      string a,b,c,ab;
      int t;
      for(t=0;t<int(s.size())&&s[t]!='+';t++){
        if(s[t]!='X'){
          a.push_back(s[t]);
        }
        else{
          a.push_back(i+'0');
        }
      }
      for(t++;t<int(s.size())&&s[t]!='=';t++){
        if(s[t]!='X'){
          b.push_back(s[t]);
        }
        else{
          b.push_back(i+'0');
        }
      }
      for(t++;t<int(s.size());t++){
        if(s[t]!='X'){
          c.push_back(s[t]);
        }
        else{
          c.push_back(i+'0');
        }
      }
      reverse(a.begin(),a.end());
      reverse(b.begin(),b.end());
      reverse(c.begin(),c.end());
      int j;
      int k=0;
      int l=0;
      for(j=0;j<int(a.size())&&j<int(b.size());j++){
        k=0;
        if(a[j]-'0'+b[j]-'0'+l>=10){
          k++;
          ab.push_back(a[j]-'0'+b[j]+l-10);
        }
        else{
          ab.push_back(a[j]-'0'+b[j]+l);
        }
        l=k;
      }
      for(;j<int(a.size());j++){
        k=0;
        if(a[j]-'0'+l>=10){
          k++;
          ab.push_back(a[j]+l-10);
        }
        else{
          ab.push_back(a[j]+l);
        }
        l=k;
      }
      for(;j<int(b.size());j++){
        k=0;
        if(b[j]-'0'+l>=10){
          k++;
          ab.push_back(b[j]+l-10);
        }
        else{
          ab.push_back(b[j]+l);
        }
        l=k;
      }
      if(l>0){
        ab.push_back(l+'0');
      }
      if(ab==c){
        f++;
        cout << i << endl;
        break;
      }
    }
    if(f==0){
      cout << "NA" << endl;
    }
    s="";
    cin >> s;
  }
}

