#include<cstdio>
#include<string>
#include<cstring>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

string solve(const string &s){
	int n=s.length();
	static int dp[2001][2001],from[2001][2001];

	rep(i,n+1) dp[i][0]=dp[0][i]=0, from[i][0]=from[0][i]=-1;

	rep(i,n) rep(j,n-i) {
		if(s[i]==s[n-j-1]){
			dp[i+1][j+1]=dp[i][j]+1;
			from[i+1][j+1]=2;
		}
		else{
			if(dp[i][j+1]<dp[i+1][j]){
				dp[i+1][j+1]=dp[i+1][j];
				from[i+1][j+1]=1;
			}
			else{
				dp[i+1][j+1]=dp[i][j+1];
				from[i+1][j+1]=0;
			}
		}
	}

	int len=0,i_len[2];
	for(int i=1;i<n;i++){
		int tmp=2*dp[i][n-i];
		if(len<tmp){
			len=tmp;
			i_len[0]=i;
			i_len[1]=n-i;
		}

		tmp=2*dp[i][n-i-1]+1;
		if(len<tmp){
			len=tmp;
			i_len[0]=i;
			i_len[1]=n-i-1;
		}
	}

	int idx=dp[i_len[0]][i_len[1]];
	string ans(idx,'@');
	for(int i=i_len[0],j=i_len[1];~from[i][j];){
		switch(from[i][j]){
			case 0: i--; break;
			case 1: j--; break;
			case 2: i--; j--; idx--; ans[idx]=s[i]; break;
		}
	}
	if(len%2==1) ans+=s[i_len[0]];
	rep(i,len/2) ans+=ans[len/2-i-1];

	return ans;
}

int main(){
	for(char s[2001];~scanf("%s",s);) puts(solve(s).c_str());
	return 0;
}