#include<iostream>
#include<string>
#include<tuple>
#include<algorithm>
using namespace std;
string S; tuple<int, int, int>dp[2100][2100];
int solve(int s, int t) {
	if (s > t)return 0;
	if (get<0>(dp[s][t]) != -1)return get<0>(dp[s][t]);
	if (s == t) { dp[s][t] = make_tuple(1, -1, -1); return 1; }
	if (t - s == 1) {
		if (S[s] == S[t]) { dp[s][t] = make_tuple(2, -1, -1); return 2; }
	}
	int c1 = solve(s, t - 1);
	int c2 = solve(s + 1, t);
	int c3 = solve(s + 1, t - 1); if (S[s] == S[t])c3 += 2;
	if (c1 >= c2 && c1 >= c3) { dp[s][t] = make_tuple(c1, s, t - 1); return c1; }
	if (c2 >= c1 && c2 >= c3) { dp[s][t] = make_tuple(c2, s + 1, t); return c2; }
	if (c3 >= c1 && c3 >= c2) { dp[s][t] = make_tuple(c3, s + 1, t - 1); return c3; }
}
int main() {
	while (cin >> S) {
		for (int i = 0; i < S.size(); i++) { for (int j = 0; j < S.size(); j++)dp[i][j] = make_tuple(-1, 0, 0); }
		solve(0, S.size() - 1);
		string V, W; int F = 0, G = S.size() - 1;
		while (F + G >= 0) {
			int H = get<1>(dp[F][G]), I = get<2>(dp[F][G]);
			if (H == -1 || ((H - F) + (G - I)) == 2) {
				V += S[F]; if (F != G)W += S[F];
			}
			F = H; G = I;
		}
		reverse(W.begin(), W.end());
		cout << V + W << endl;
	}
	return 0;
}