Problem: Given a string s, determine if it contains any palindrome of length exactly 100 as a subsequence. If it has any, print any one of them. If it doesn't have any, print a palindrome that is a subsequence of s and is as long as possible.

Input

The only line of the input contains one string s of length n (1 ≤ n ≤ 5·104) containing only lowercase English letters.

Output

If s contains a palindrome of length exactly 100 as a subsequence, print any palindrome of length 100 which is a subsequence of s. If s doesn't contain any palindromes of length exactly 100, print a palindrome that is a subsequence of s and is as long as possible.

If there exists multiple answers, you are allowed to print any of them.

Examples

Input

bbbabcbbb


Output

bbbcbbb


Input

rquwmzexectvnbanemsmdufrg


Output

rumenanemur

Note

A subsequence of a string is a string that can be derived from it by deleting some characters without changing the order of the remaining characters. A palindrome is a string that reads the same forward or backward.

Solution (in CPP):

Solution:
#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;
}