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

int main()
{
  string s;
  while (cin >> s) {
    bool found = false;
    for (int i = 0; i <= 9; ++i) {
      int idx = 0;
      vector<int> num(3, 0);
      for (unsigned int j = 0; j < s.size(); ++j) {
	if (s[j] == '+' || s[j] == '=') {
	  ++idx;
	  continue;
	}
	num[idx] *= 10;
	if (s[j] == 'X')
	  num[idx] += i;
	else
	  num[idx] += s[j] - '0';
      }

      if (num[0] + num[1] == num[2]) {
	found = true;
	cout << i << endl;
	break;
      }
    }
    if (!found)
      cout << "NA" << endl;
  }
  return 0;
}