#include <bits/stdc++.h>
using namespace std;
const int maxN = 5 * 10000 + 10;
vector<int> v[26];
int dp[maxN][110];
char lps[maxN];
bool mark[maxN];
int main() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    v[s[i] - 'a'].push_back(i);
  }
  memset(dp, 63, sizeof dp);
  for (int i = 0; i < n; i++) {
    dp[i][1] = i;
    dp[i][0] = i - 1;
  }
  int ans = 1;
  for (int k = 2; k <= min(n, 100); k++) {
    for (int i = n - k + 1; i--;) {
      dp[i][k] = dp[i + 1][k];
      int x = s[i] - 'a';
      if (v[x].back() > dp[i + 1][k - 2]) {
        int dw = -1;
        int up = v[x].size();
        while (up - dw > 1) {
          int md = (dw + up) / 2;
          if (v[x][md] > dp[i + 1][k - 2])
            up = md;
          else
            dw = md;
        }
        dp[i][k] = min(dp[i][k], v[x][up]);
      }
      if (dp[i][k] < 1e9) {
        ans = k;
      }
    }
  }
  int x = ans;
  int t = 0;
  int T = n;
  while (x >= 1) {
    for (int i = T; i--;) {
      if (dp[i][x] < T && s[i] == s[dp[i][x]]) {
        lps[t + 1] = s[i];
        lps[ans - t] = s[dp[i][x]];
        t++;
        T = dp[i][x];
        break;
      }
    }
    x -= 2;
  }
  for (int i = 1; i <= ans; i++) {
    cout << lps[i];
  }
  cout << endl;
  return 0;
}
