import java.io.*; public class MadamImAdam_MemoizedDFS_dmikurube { private static final int NODIRECTION = 0; private static final int RIGHT = 1; private static final int UP = 2; private static final int UPRIGHT = 3; private static final int DIAG = 4; private static int[][] length; private static int[][] direct; private static String line; private static int DFS(int left, int right) { if (length[left][right] > 0) { return length[left][right]; } if (left > right) { return 0; } int result, result1, result2; result1 = DFS(left+1, right); result2 = DFS(left, right-1); if (result1 > result2) { result = result1; direct[left][right] = RIGHT; } else { result = result2; direct[left][right] = UP; } if (line.charAt(left) == line.charAt(right)) { int result3 = DFS(left+1, right-1) + 2; if (result3 > result) { result = result3; direct[left][right] = DIAG; } } length[left][right] = result; return result; } private static int Solve() { length = new int[line.length()][line.length()]; direct = new int[line.length()][line.length()]; for (int i = 0; i < line.length(); i++) { for (int j = 0; j < line.length(); j++) { if (i == j) { length[i][j] = 1; } else { length[i][j] = 0; } direct[i][j] = NODIRECTION; } } return DFS(0, line.length()-1); } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (null != (line = br.readLine())) { Solve(); /* It's so shoddy. */ { String result_left = "", result_right = "", result = ""; int l = 0, r = line.length() - 1; while (true) { if (direct[l][r] == NODIRECTION) { if (length[l][r] == 1) { result = result_left + line.charAt(l) + result_right; } else { result = result_left + result_right; } break; } else if (direct[l][r] == DIAG) { result_left = result_left + line.charAt(l); result_right = line.charAt(r) + result_right; l++; r--; } else if (direct[l][r] == UP) { r--; } else { l++; } } System.out.println(result); } } } }