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>
#pragma GCC optimize("O3")
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
template <typename T, size_t N>
int SIZE(const T (&t)[N]) {
  return N;
}
template <typename T>
int SIZE(const T &t) {
  return t.size();
}
string to_string(const string s, int x1 = 0, int x2 = 1e9) {
  return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"';
}
string to_string(const char *s) { return to_string((string)s); }
string to_string(const bool b) { return (b ? "true" : "false"); }
string to_string(const char c) { return string({c}); }
template <size_t N>
string to_string(const bitset<N> &b, int x1 = 0, int x2 = 1e9) {
  string t = "";
  for (int __iii__ = min(x1, SIZE(b)), __jjj__ = min(x2, SIZE(b) - 1);
       __iii__ <= __jjj__; ++__iii__) {
    t += b[__iii__] + '0';
  }
  return '"' + t + '"';
}
template <typename A, typename... C>
string to_string(const A(&v), int x1 = 0, int x2 = 1e9, C... coords);
int l_v_l_v_l = 0, t_a_b_s = 0;
template <typename A, typename B>
string to_string(const pair<A, B> &p) {
  l_v_l_v_l++;
  string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
  l_v_l_v_l--;
  return res;
}
template <typename A, typename... C>
string to_string(const A(&v), int x1, int x2, C... coords) {
  int rnk = rank<A>::value;
  string tab(t_a_b_s, ' ');
  string res = "";
  bool first = true;
  if (l_v_l_v_l == 0) res += '\n';
  res += tab + "[";
  x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v));
  auto l = begin(v);
  advance(l, x1);
  auto r = l;
  advance(r, (x2 - x1) + (x2 < SIZE(v)));
  for (auto e = l; e != r; e = next(e)) {
    if (!first) {
      res += ", ";
    }
    first = false;
    l_v_l_v_l++;
    if (e != l) {
      if (rnk > 1) {
        res += '\n';
        t_a_b_s = l_v_l_v_l;
      };
    } else {
      t_a_b_s = 0;
    }
    res += to_string(*e, coords...);
    l_v_l_v_l--;
  }
  res += "]";
  if (l_v_l_v_l == 0) res += '\n';
  return res;
}
void dbgm() { ; }
template <typename Heads, typename... Tails>
void dbgm(Heads H, Tails... T) {
  cout << to_string(H) << " | ";
  dbgm(T...);
}
const long long MOD = (int)1e9 + 7;
string ascii_lowercase = "abcdefghijklmnopqrstuvwxyz";
string ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct hashLL {
  size_t operator()(long long x) const {
    x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
    x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb);
    x = x ^ (x >> 31);
    return x;
  }
};
long long inv(long long a, long long b) {
  return 1 < a ? b - inv(b % a, a) * b / a : 1;
}
const long long INF = 1e6;
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long distsq(long long x1, long long y1, long long x2, long long y2) {
  return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}
const int N = 50004;
long long n, m;
string s;
map<pair<long long, long long>, pair<char, long long>> mp;
map<char, long long> prv[N];
map<char, long long> nxt[N];
pair<char, long long> dfs(long long l, long long r, long long iterations) {
  if (mp.count(make_pair(l, r))) {
    return mp[make_pair(l, r)];
  }
  if (iterations > 52) {
    mp[make_pair(l, r)] = make_pair('~', 0);
    return mp[make_pair(l, r)];
  }
  long long base = 0;
  char bestc = '~';
  long long bestnum = 0;
  if (s[l] == s[r]) {
    base = 2;
  }
  for (char c = 'a'; c <= 'z'; c++) {
    if (prv[r][c] < nxt[l][c]) continue;
    long long curr = 0;
    if (prv[r][c] == nxt[l][c]) {
      curr = 1;
    } else {
      curr = dfs(nxt[l][c], prv[r][c], iterations + 1).second;
    }
    if (curr > bestnum) {
      bestnum = curr;
      bestc = c;
    }
  }
  mp[make_pair(l, r)] = make_pair(bestc, base + bestnum);
  return mp[make_pair(l, r)];
}
string revv = "";
void print(long long l, long long r, long long numprinted) {
  if (numprinted == 100) return;
  if (l == r) {
    cout << s[l];
    return;
  }
  cout << s[l];
  revv += s[l];
  char c = mp[make_pair(l, r)].first;
  if (c == '~') return;
  print(nxt[l][c], prv[r][c], numprinted + 2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  s = '0' + s + '9';
  n = s.size();
  map<char, long long> toidx;
  for (char c = 'a'; c <= 'z'; c++) toidx[c] = 1e6;
  for (int i = n - 1; i >= 0; i--) {
    for (char c = 'a'; c <= 'z'; c++) {
      nxt[i][c] = toidx[c];
    }
    toidx[s[i]] = i;
  }
  toidx.clear();
  for (char c = 'a'; c <= 'z'; c++) toidx[c] = -1;
  for (int i = 0; i < n; i++) {
    for (char c = 'a'; c <= 'z'; c++) {
      prv[i][c] = toidx[c];
    }
    toidx[s[i]] = i;
  }
  dfs(0, n - 1, 0);
  char c = mp[make_pair(0, n - 1)].first;
  print(nxt[0][c], prv[n - 1][c], 0);
  reverse(revv.begin(), revv.end());
  cout << revv;
  return 0;
}