import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); StringBuilder sb = new StringBuilder(sc.next()); int length = sb.length(); boolean result; if (length % 2 == 0) { result = (getResult(sb, length / 2 - 1, length / 2 - 1, true) || getResult(sb, length / 2, length / 2, false)); } else { result = (getResult(sb, length / 2 - 1, length / 2, true) || getResult(sb, length / 2, length / 2 + 1, false)); } if (result) { System.out.println(sb); } else { System.out.println("NA"); } } static boolean getResult(StringBuilder sb, int left, int right, boolean isLeft) { int idx = -1; char ch = (char)0; while (left >= 0 && right < sb.length()) { if (sb.charAt(left) != sb.charAt(right)) { if (idx >= 0) { return false; } if (isLeft) { idx = left; ch = sb.charAt(right); right++; } else { idx = right; ch = sb.charAt(left); left--; } } else { left--; right++; } } if (idx < 0) { if (isLeft) { idx = 0; ch = sb.charAt(sb.length() - 1); } else { idx = sb.length(); ch = sb.charAt(0); } } sb.insert(idx, ch); return true; } }