#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
int main() {
  string s, tmp = "", ss, rss, rtmp;
  cin >> s;
  int siz = s.length() - 1;
  bool f = 0;
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] == s[siz - i])
      continue;
    else {
      tmp = "";
      ss = "";
      for (int j = 0; j < s.length(); j++) {
        if (j == i) tmp = tmp + s[siz - i];
        tmp = tmp + s[j];
        ss = ss + s[j];
        if (j == siz - i) ss = ss + s[i];
      }
      f = 1;
      break;
    }
  }
  if (f) {
    rtmp = tmp;
    rss = ss;
    reverse(rss.begin(), rss.end());
    reverse(rtmp.begin(), rtmp.end());
    if (ss == rss)
      cout << ss << endl;
    else if (rtmp == tmp)
      cout << tmp << endl;
    else
      cout << "NA\n";
  } else {
    for (int i = 0; i < s.length(); i++) {
      tmp = tmp + s[i];
      if (i == siz / 2) tmp = tmp + s[siz / 2];
    }
    rtmp = tmp;
    reverse(rtmp.begin(), rtmp.end());
    if (rtmp == tmp)
      cout << tmp << endl;
    else
      cout << "NA\n";
  }
  return 0;
}
