#include <iostream>
#include <string>
using namespace std;

int p;
string eq;

void getnum(int &v, int &x) {
  char c;
  v = x = 0;
  while (1) {
    c = eq[p];
    if (isdigit(c)) {
      v *= 10;
      x *= 10;
      v += c-'0';
    } else if (c=='X') {
      v *= 10;
      x *= 10;
      x++;
    } else {
      break;
    }
    p++;
  }
}

int main() {
  int l1, l2, r, l1x, l2x, rx, a, b, c;
  while (getline(cin, eq)) {
    p = 0;
    getnum(l1, l1x);
    p++;
    getnum(l2, l2x);
    p++;
    getnum(r, rx);
    a = l1x + l2x - rx;
    b = r - l1 - l2;
    if (a) {
      c = b / a;
      if (c<0 || c>9 || b-c*a) c = -1;
    } else {
      c = -1;
    }
    if (c<0) {
      cout << "NA" << endl;
    } else {
      cout << c << endl;
    }
  }
  return 0;
}