#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  int a,b,c,x,y,z;
  char d;
  a = b = c = x = y = z = 0;
  while((scanf("%c",&d)) != EOF){
    if(d == 'X') x = 1;
    else a = d - '0';
    while(scanf("%c",&d), d != '+'){
      a *= 10; x *= 10;
      if(d == 'X') x += 1;
      else a += d - '0';
    }
    while(scanf("%c",&d), d != '='){
      b *= 10; y *= 10;
      if(d == 'X') y += 1;
      else b += d - '0';
    }
    while(scanf("%c",&d), d != '\n'){
      c *= 10; z *= 10;
      if(d == 'X') z += 1;
      else c += d - '0';
    }
    int i;
    for(i=0;i<10;i++){
      if((a + i * x) + (b + i * y) == c + i * z) break;
    }
    if(i == 10) cout << "NA" << endl;
    else cout << i << endl;
    a = b = c = x = y = z = 0;
  }
  return 0;
}