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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Solution{
	

	static char[] s;
	static int n;
	static int[][] cache;
	
	
    public static void main(String[] args) throws IOException {
     
    	FastScanner fs = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    	
    	
    		
    	int tt = 1;
    	while(tt-->0) {
    		
    		s = fs.next().toCharArray();
    		n = s.length;
    		
    		int[] cnt = new int[26];
    		for(int i=0;i<n;i++) cnt[s[i]-'a']++;
    		
    		for(int i=0;i<26;i++) {
    			if(cnt[i]>=100) {
    				for(int j=0;j<100;j++) {
    					out.print((char)('a'+i));
    				}
    				out.flush();
    				return;
    			}
    		}
    		
    		if(n>=2600) new RuntimeException();
    		
    		//cache[i][j] -- stores the longest palindromic subsequence from i - j
    		cache = new int[n][n];
    		for(int i=0;i<n;i++) for(int j=0;j<n;j++) cache[i][j] = -1;
    		
    		dp(0, n-1);
    		
    		
    		ArrayDeque<Character> q = new ArrayDeque<>();
    		
    		
    		int i = 0, j = n-1;
    		while(i<j) {
    			if(s[i]==s[j]) {
    				q.add(s[i]); 
    				i++; j--;
    			}
    			else if(cache[i+1][j]>cache[i][j-1]) i++;
    			else j--;
    		}
    		
    		int len = Math.min(2*q.size()+((i==j)?1:0), 100);
    		
    		if(len==100) {
    			StringBuilder st = new StringBuilder();
    			for(int k=0;k<50;k++) {
    				st.append(q.pollFirst());
    			}
    			out.print(st.toString());
    			st.reverse();
    			out.print(st.toString());
    		}
    		
    		else {
    			for(Character ch: q) {
        			out.print(ch);
        		}
        		if(i==j) out.print(s[i]);
        		Iterator<Character> iter = q.descendingIterator();
        		while(iter.hasNext()) out.print(iter.next());
        		out.println();
    		}
    		
    		
    		
    		
    		
    	}
    	
    		
    		
    		
    	out.close();
    		
    }
    
    
    
    static int dp(int i, int j) {
    	if(cache[i][j]!=-1) return cache[i][j];
    	if(i==j) return cache[i][j] = 1;
    	if(i>j) return cache[i][j] = 0;
    	if(s[i]==s[j]) return cache[i][j] = 2 + dp(i+1, j-1);
    	return cache[i][j] = Math.max(dp(i+1, j), dp(i, j-1));
    	
    }
    
    
    
    
    
    static final Random random=new Random();
    	
    static void ruffleSort(int[] a) {
    	int n=a.length;//shuffle, then sort 
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); int temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }
   
  
    
    static void reverse(int[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++){
    		int temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }
    
    static void reverse(long[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++){
    		long temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }
    
    
    static <T> void reverse(T[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++) {
    		T temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }
    	
    	
    static class FastScanner{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
     
    	public String next(){
    		while(!st.hasMoreElements()){
    			try{
    				st = new StringTokenizer(br.readLine());
    			} catch(IOException e){
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}
    		
    	public String nextLine() throws IOException {
    		return br.readLine();
    	}
    		
    	public int nextInt(){
    		return Integer.parseInt(next());
    	}
     
    	public int[] readArray(int n){
    		int[] a = new int[n];
    		for(int i=0;i<n;i++)
    			a[i] = nextInt();
    		return a;
    	}
    		
    	public long nextLong() {
    		return Long.parseLong(next());
    	}
    		
    	public char nextChar() {
    		return next().toCharArray()[0];
    	}
    }
   	
}