#include <bits/stdc++.h>
using namespace std;
using std::map;
const int CMAX = 0;
int main() {
  string s, ss;
  int c = 0;
  bool possible = true;
  cin >> ss;
  s = ss;
  int pos = -1;
  char ch;
  for (int i = 0; i < s.length() / 2; i++) {
    if (pos == -1 && s[i] != s[s.length() - i - 1]) {
      pos = i;
      ch = s[s.length() - i - 1];
      i--;
    } else if (pos != -1 && s[i] != s[s.length() - i - 2]) {
      possible = false;
      break;
    }
  }
  if (possible) {
    if (pos != -1)
      for (int i = 0; i < s.length(); i++) {
        if (i == pos) cout << ch;
        cout << s[i];
      }
    else
      for (int i = 0; i < s.length(); i++) {
        if (i == s.length() / 2) cout << s[i];
        cout << s[i];
      }
  } else {
    possible = true;
    pos = -1;
    for (int i = 0; i < s.length() / 2; i++) {
      if (pos == -1 && s[i] != s[s.length() - i - 1]) {
        pos = s.length() - i - 1;
        ch = s[i];
        i--;
      } else if (pos != -1 && s[i + 1] != s[s.length() - i - 1]) {
        possible = false;
        break;
      }
    }
    if (possible) {
      if (pos != -1)
        for (int i = 0; i < s.length(); i++) {
          cout << s[i];
          if (i == pos) cout << ch;
        }
      else
        for (int i = 0; i < s.length(); i++) {
          if (i == s.length() / 2) cout << s[i];
          cout << s[i];
        }
    } else
      cout << "NA";
  }
  return 0;
}
