#include <bits/stdc++.h>
using namespace std;
template <class X>
void input(vector<X>& a, int N) {
  X temp;
  for (long long int i = 0; i < N; i++) {
    cin >> temp;
    a.push_back(temp);
  }
}
bool isPalin(string s) {
  string temp = s;
  reverse(temp.begin(), temp.end());
  return temp == s;
}
void solve() {
  string s;
  cin >> s;
  if (isPalin(s)) {
    string ans = "";
    ans.push_back(s[s.length() / 2]);
    s.insert(s.length() / 2, ans);
    cout << s;
    return;
  }
  string temp1, temp2;
  int i = 0;
  int j = s.length() - 1;
  while (i < j) {
    if (s[i] == s[j]) {
      i++;
      j--;
    } else {
      string ans1, ans2;
      ans1 = "";
      ans2 = "";
      ans1.push_back(s[i]);
      ans2.push_back(s[j]);
      temp1 = s;
      temp2 = s;
      temp1.insert(i, ans2);
      temp2.insert(j + 1, ans1);
      if (isPalin(temp1)) {
        cout << temp1;
        return;
      }
      if (isPalin(temp2)) {
        cout << temp2;
        return;
      }
      cout << "NA";
      return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
