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.Arrays; import java.util.Iterator; public class Main_yukicoder238_1 { 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; int offset; for (offset = 0; offset < n; offset++) { if (s[offset] != s[n - 1 - offset]) { break; } } if (offset == n) { StringBuilder ret = new StringBuilder(); int len = (n + 1) / 2; ret.append(s, 0, len); ret.append(s[len - 1]); ret.append(s, len, n - len); pr.println(ret); } else { StringBuilder ret = new StringBuilder(); ret.append(s); ret.insert(offset, s[n - 1 - offset]); boolean res = true; for (int i = 0; i < ret.length(); i++) { if (ret.charAt(i) != ret.charAt(ret.length() - 1 - i)) { res = false; break; } } if (res) { pr.println(ret); } else { ret = new StringBuilder(); ret.append(s); ret.insert(n - offset, s[offset]); res = true; for (int i = 0; i < ret.length(); i++) { if (ret.charAt(i) != ret.charAt(ret.length() - 1 - i)) { res = false; break; } } if (res) { 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); } } }