#include <bits/stdc++.h>
using namespace std;
bool ispalindrome(string s) {
  int low = 0;
  int high = s.length() - 1;
  while (low < high) {
    if (s[low] != s[high]) {
      return false;
    }
    low += 1;
    high -= 1;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  if (ispalindrome(s)) {
    int len = s.length();
    len /= 2;
    char ch = s[len];
    for (int i = 0; i <= len; i++) {
      cout << s[i];
    }
    cout << ch;
    for (int i = len + 1; i < s.length(); i++) {
      cout << s[i];
    }
  } else {
    int low = 0;
    int high = s.length() - 1;
    while (low < high) {
      if (s[low] != s[high]) {
        break;
      }
      low += 1;
      high -= 1;
    }
    string new1 = "";
    string new2 = "";
    for (int i = 0; i < low; i++) {
      new1 += s[i];
    }
    new1 += s[high];
    for (int i = low; i < s.length(); i++) {
      new1 += s[i];
    }
    for (int i = 0; i <= high; i++) {
      new2 += s[i];
    }
    new2 += s[low];
    for (int i = high + 1; i < s.length(); i++) {
      new2 += s[i];
    }
    if (ispalindrome(new1)) {
      cout << new1;
    } else if (ispalindrome(new2)) {
      cout << new2;
    } else
      cout << "NA";
  }
}
