import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int left = 0; int right = s.length() - 1; int idx = -1; char c = ' '; while (left <= right) { if (s.charAt(left) == s.charAt(right)) { left++; right--; continue; } if (s.charAt(left + 1) == s.charAt(right)) { if (idx >= 0) { System.out.println("NA"); return; } idx = right + 1; c = s.charAt(left); left++; } else if (s.charAt(left) == s.charAt(right - 1)) { if (idx >= 0) { System.out.println("NA"); return; } idx = left; c = s.charAt(right); right--; } else { System.out.println("NA"); return; } } if (idx < 0) { if (s.length() % 2 == 0) { idx = s.length() / 2; c = 'a'; } else { idx = s.length() / 2; c = s.charAt(idx); } } s = new StringBuilder(s).insert(idx, c).toString(); System.out.println(s); } }