#include <iostream>
#include <string>
#include <cassert>
#include <cstdio>
#include <cctype>

namespace {

bool can_assign_zero(const std::string& str)
{
  return (str.size() <= 1) || (str[0] != 'X');
}

int assign_digit(const std::string& str, int x)
{
  int value = 0;

  for (size_t i = 0; i < str.size(); ++i) {
    if (str[i] == 'X')
      value = (value * 10) + x;
    else 
      value = (value * 10) + (str[i] - '0');
  }

  return value;
}

} // unnamed namespace

int main()
{
  std::string str;
  while (std::cin >> str) {
    const size_t add_pos = str.find('+');
    const size_t eq_pos = str.find('=');

    assert(add_pos != std::string::npos);
    assert(eq_pos != std::string::npos);

    const std::string v1 = str.substr(0, add_pos);
    const std::string v2 = str.substr(add_pos + 1, eq_pos - add_pos - 1);
    const std::string sum = str.substr(eq_pos + 1, str.size() - eq_pos);
    
    const int init_number =
      (can_assign_zero(v1) && can_assign_zero(v2) && can_assign_zero(sum)) ? 0 : 1;

    int n;
    for (n = init_number; n < 10; ++n) {
      if (assign_digit(v1, n) + assign_digit(v2, n) == assign_digit(sum, n)) {
        std::cout << n << std::endl;
        break;
      }
    }

    if (n == 10) {
      std::cout << "NA" << std::endl;
    }
  }
  return 0;
}