#include <bits/stdc++.h>
using namespace std;
string reverse(const string& in) {
  stringstream str;
  for (string::const_reverse_iterator it = in.crbegin(); it != in.crend();
       ++it) {
    str << *it;
  }
  return str.str();
}
string get_palindrome(string& instr, string& reversed, bool recurse = true) {
  unsigned int num_mismatches = 0;
  unsigned int num_X = 0;
  std::string reversed_saved;
  string::iterator X_it, X_src_it;
  if (recurse && instr.size() == 1) {
    instr.push_back(instr[0]);
    return instr;
  }
  if (recurse) {
    reversed_saved = reversed;
  }
  do {
    string::iterator it1 = instr.begin();
    string::iterator it2 = reversed.begin();
    string::iterator end = instr.end();
    num_mismatches = 0;
    num_X = 0;
    while (*it1 == *it2 && it1 != instr.end()) {
      ++it1;
      ++it2;
      --end;
    }
    if (it1 == instr.end()) {
      break;
    }
    while (it1 != end) {
      if (*it2 == 'X') {
        num_X++;
        X_src_it = it1;
        X_it = it2;
      } else if (*it1 != *it2) {
        reversed.insert(it2, 'X');
        num_mismatches++;
        break;
      }
      if (num_X > 1) {
        break;
      }
      ++it1;
      ++it2;
    }
    if (num_X > 1) {
      break;
    }
  } while (num_mismatches != 0);
  if (num_X > 1) {
    if (recurse) {
      return get_palindrome(reversed_saved, instr, false);
    } else {
      return "NA";
    }
  } else if (num_X == 1) {
    *X_it = *X_src_it;
    return reversed;
  } else {
    stringstream outstr;
    size_t insert_idx = instr.size() / 2;
    outstr << instr.substr(0, insert_idx) << instr[insert_idx]
           << instr.substr(insert_idx, string::npos);
    return outstr.str();
  }
}
void kitayuta_main(istream& sin, ostream& sout) {
  string instr;
  while (sin) {
    sin >> instr;
    if (sin) {
      size_t reserve_size = instr.size() + 1;
      instr.reserve(reserve_size);
      std::string reversed = reverse(instr);
      reversed.reserve(reserve_size);
      sout << get_palindrome(instr, reversed) << endl;
    }
  }
}
int main(int argc, char* argv[]) {
  kitayuta_main(cin, cout);
  return 0;
}
