#include <bits/stdc++.h>
using namespace std;
bool check(string a) {
  string b = a;
  reverse(a.begin(), a.end());
  return a == b;
}
int main() {
  string s2;
  cin >> s2;
  string s = s2;
  reverse(s2.begin(), s2.end());
  int pos = s.size() / 2;
  char c = 'w';
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != s2[i]) {
      pos = i;
      break;
    }
  }
  string a, b;
  a = s.substr(0, pos) + s2[pos] + s.substr(pos, s.size() - pos);
  b = s2.substr(0, pos) + s[pos] + s2.substr(pos, s.size() - pos);
  if (check(a))
    cout << a;
  else if (check(b))
    cout << b;
  else
    cout << "NA";
  return 0;
}
