import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.Arrays; import java.util.Iterator; import java.util.Queue; public class Main_yukicoder238 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); char[] s = sc.next().toCharArray(); int n = s.length; Queue fq = new ArrayDeque(); Queue rq = new ArrayDeque(); boolean flag = false; for (int i = 0; i < n; i++) { if (!flag && s[i] != s[n - 1 - i]) { rq.add(s[i]); fq.add(s[n - 1 - i]); flag = true; } fq.add(s[i]); rq.add(s[n - 1 - i]); } if (!flag) { StringBuilder ret = new StringBuilder(); int len = (n + 1) / 2; for (int i = 0; i < len; i++) { ret.append(s[i]); } ret.append(s[len - 1]); for (int i = len; i < n; i++) { ret.append(s[i]); } pr.println(ret); } else { Character[] tmp = new Character[0]; tmp = fq.toArray(tmp); boolean res = true; for (int i = 0; i < tmp.length; i++) { if (tmp[i] != tmp[tmp.length - 1 - i]) { res = false; break; } } if (res) { StringBuilder ret = new StringBuilder(); for (int i = 0; i < tmp.length; i++) { ret.append(tmp[i]); } pr.println(ret); pr.close(); sc.close(); return; } Character[] tmp2 = new Character[0]; tmp2 = rq.toArray(tmp2); boolean res2 = true; for (int i = 0; i < tmp2.length; i++) { if (tmp2[i] != tmp2[tmp2.length - 1 - i]) { res2 = false; break; } } if (res2) { StringBuilder ret = new StringBuilder(); for (int i = 0; i < tmp2.length; i++) { ret.append(tmp2[i]); } pr.println(ret); } else { pr.println("NA"); } } pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }