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;
int cnt[26], dp[2602][2602];
bool trace[2602][2602];
int main() {
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < s.length(); ++i) {
    ++cnt[s[i] - 'a'];
    if (cnt[s[i] - 'a'] == 100) {
      for (int j = 1; j <= 100; ++j) cout << s[i];
      return 0;
    }
  }
  for (int i = 0; i <= n; ++i) {
    dp[i][i] = 1;
  }
  for (int k = 1; k < n; ++k) {
    for (int i = 0; i + k < n; ++i) {
      int j = i + k;
      if (s[i] == s[j]) {
        dp[i][j] = dp[i + 1][j - 1] + 2;
        trace[i][j] = 1;
      } else {
        dp[i][j] = max(dp[i + 1][j], dp[i][j - 1]);
      }
    }
  }
  if (dp[0][n - 1] == 1) {
    cout << s[0];
    return 0;
  }
  int l = 0, r = n - 1;
  string s1, s2;
  int cl, cr;
  while (l <= r) {
    if (trace[l][r] == 1) {
      cl = l;
      cr = r;
      s1 += s[l];
      s2 += s[r];
      l++;
      r--;
    } else {
      if (dp[l + 1][r] >= dp[l][r - 1]) {
        l++;
      } else
        r--;
    }
    if (s1.length() >= 50 || s2.length() >= 50) break;
  }
  if (cl != cr - 1 && s1.length() < 50) s2 += s[cl + 1];
  reverse(s2.begin(), s2.end());
  cout << s1 << s2;
}