#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  string s;
  while(cin >> s){
    int N = s.size();
    int dp[2001] = {}; // dp[i] = [i, s.size())まで使ったときの最大の文字列
    static int prev[2001][2001] = {};
    memset(prev, -1, sizeof(prev));
    vector<int> indexes[26];
    REP(i, N) indexes[s[i] - 'A'].push_back(i);
    REP(i, N){
      // center
      if(dp[i] < dp[i + 1] + 1){
        dp[i] = dp[i + 1] + 1;
        prev[i + 1][i] = i + 1;
      }
      for(int j = i + 1; j < N; j++){
        //[i + 1, j + 1) = [i + 1, j]
        int cur = dp[j + 1];
        vector<int>& v = indexes[s[i] - 'A'];
        int idx = upper_bound(v.begin(), v.end(), j) - v.begin() - 1;  // j以下で最大
        if(0 <= idx && idx < v.size() && i + 1 <= v[idx] && dp[v[idx]] < cur + 2){
          dp[v[idx]] = cur + 2;
          prev[i + 1][v[idx]] = j + 1;
        }
      }
    }
    int max_c = 0;
    REP(i, N + 1) if(dp[max_c] < dp[i]) max_c = i;
    int curr = max_c;
    string ans;
    for(int i = N - 1; i >= 0; i--){
      if(prev[i + 1][curr] == -1){
      }else{
        if(i != curr) ans = s[i] + ans + s[curr];
        else ans = s[i];
        curr = prev[i + 1][curr];
      }
    }
    cout << ans << endl;
  }
  return 0;
}