#include <bits/stdc++.h>
using namespace std;
const int N = 50000 + 5;
char s[N];
vector<char> pr;
int pre[N][33], pos[N][55];
void dfs(int i, int c) {
  if (c == 0) return;
  char ch = s[pos[i][c]];
  dfs(pre[i][ch - 'a'] - 1, c - 1);
  pr.push_back(ch);
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 26; j++) pre[i][j] = pre[i - 1][j];
    pre[i][s[i] - 'a'] = i;
  }
  memset(pos, -1, sizeof(pos));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < 50; j++) pos[i][j] = pos[i - 1][j];
    for (int j = 49; j >= 1; j--)
      if (pos[i - 1][j] != -1) {
        if (pre[pos[i - 1][j] - 1][s[i] - 'a'] > i) {
          pos[i][j + 1] =
              max(pos[i][j + 1], pre[pos[i - 1][j] - 1][s[i] - 'a']);
        }
      }
    if (pre[n][s[i] - 'a'] > i) pos[i][1] = max(pos[i][1], pre[n][s[i] - 'a']);
    if (pos[i][50] != -1) {
      dfs(i, 50);
      for (int j = 0; j < pr.size(); j++) printf("%c", pr[j]);
      for (int j = pr.size() - 1; j >= 0; j--) printf("%c", pr[j]);
      puts("");
      return 0;
    }
  }
  int mx = -1, id;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < 50; j++)
      if (pos[i][j] != -1 && j >= mx) {
        if (j == mx && pos[i][j] > i + 1) {
          mx = j;
          id = i;
        } else if (j > mx) {
          mx = j;
          id = i;
        }
      }
  }
  if (mx == -1) {
    printf("%c\n", s[1]);
    return 0;
  }
  dfs(id, mx);
  for (int i = 0; i < pr.size(); i++) printf("%c", pr[i]);
  if (pos[id][mx] > id + 1) printf("%c", s[id + 1]);
  for (int i = pr.size() - 1; i >= 0; i--) printf("%c", pr[i]);
  puts("");
  return 0;
}
