#include<bits/stdc++.h>
using namespace std;
#define N 2050
string ss[2][N+1];
int c[N+1][N+1];
string lcs(string X,string Y){
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  ss[0][0] = "";
  memset(c,0,sizeof(c));
  for(int i=0;i<N+1;i++) ss[0][i]=ss[1][i]="";
  for(int i=0;i<=m;i++) c[i][0]=0;
  for(int j=1;j<=n;j++) c[0][j]=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1, ss[i%2][j] = ss[(i-1)%2][j-1] + X[i];
      else {
	if(c[i-1][j] >= c[i][j-1]) c[i][j]=c[i-1][j], ss[i%2][j] = ss[(i-1)%2][j];
	else c[i][j] = c[i][j-1], ss[i%2][j] = ss[i%2][j-1];
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  string ret=ss[m%2][n],ret2=ret;
  reverse(ret2.begin(),ret2.end());
  //assert(ret==ret2);
  assert((int)ret.size()==maxl);
  return ss[m%2][n];
}
int main(){
  string s;
  while(cin >> s) {
    string t = s;
    reverse(t.begin(), t.end());
    cout << lcs(s, t) << endl;
  }
  return 0;
}