import java.io.*; public class MadamImAdam_N2_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; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while (null != (line = br.readLine())) { int[][] length = new int[line.length()][line.length()]; int[][] direct = new int[line.length()][line.length()]; for (int l = 0; l < line.length(); l++) { for (int r = 0; r < line.length(); r++) { length[l][r] = 0; direct[l][r] = NODIRECTION; } } for (int lr = 0; lr < line.length(); lr++) { length[lr][lr] = 1; } for (int r = 0; r < line.length(); r++) { for (int l = r-1; l >= 0; l--) { if (line.charAt(l) == line.charAt(r)) { length[l][r] = length[l+1][r-1] + 2; direct[l][r] = DIAG; } else { if (length[l+1][r] == length[l][r-1]) { length[l][r] = length[l+1][r]; direct[l][r] = UPRIGHT; } else if (length[l+1][r] > length[l][r-1]) { length[l][r] = length[l+1][r]; direct[l][r] = RIGHT; } else { length[l][r] = length[l][r-1]; direct[l][r] = UP; } } } } /* 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); } } } }