#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)

typedef long long ll;

int main(void) {
    int i, j, n;
    string s;
    cin >> s;
    n = s.size();

    string left, right;
    i = 0; j = n-1;
    while (i < j) {
        if (s[i] != s[j])
            left.push_back(s[j]);
        else
            left.push_back(s[i++]);
        right.push_back(s[j--]);
    }
    if (n/2 - i <= 1) {
        if (i == j)
            left.push_back(s[i]);
        if (s.size() == left.size() + right.size())
            right.push_back(left.back());
        bool ok = true;
        rep (i,min(left.size(),right.size()))
            ok &= left[i] == right[i];
        if (ok) {
            reverse(right.begin(),right.end());
            cout << left + right << endl;
            return 0;
        }
    }

    left.clear(); right.clear();
    i = 0; j = n-1;
    while (i < j) {
        if (s[i] != s[j])
            right.push_back(s[i]);
        else
            right.push_back(s[j--]);
        left.push_back(s[i++]);
    }
    if (j - n/2 <= 0) {
        if (i == j)
            right.push_back(s[i]);
        if (s.size() == left.size() + right.size())
            left.push_back(left.back());
        bool ok = true;
        rep (i,min(left.size(),right.size()))
            ok &= left[i] == right[i];
        if (ok) {
            reverse(right.begin(),right.end());
            cout << left + right << endl;
            return 0;
        }
    }
    cout << "NA" << endl;
    return 0;
}