#include<iostream>
#include<vector>
#include <algorithm>
#include<stack>
#include<map>
#include<cstring>
using namespace std;
class Solution {
public:
//回文判断
bool isParlindroom(string s){
int low=0,high=s.size()-1;
while(low<high){
if(s[low]==s[high]){
low++;
high--;
}
else
return false;
}
return true;
}
string longestPalindrome(string s) {
vector<vector<int>> charsIndex(26,vector<int>(10,-1));
int maxlength=0;
string maxstring="";
for(int i=0;i<s.size();i++){
int a=s[i]-'a';
//cout<<a<<endl;
if(charsIndex[a][0]==-1)
{
charsIndex[a][0]=i;
continue;
}
//查找相同字符下标
int j=0;
for(;j<charsIndex[a].size()&&charsIndex[a][j]!=-1;j++){
//cout<<j<<" "<<charsIndex[a][j];
if(isParlindroom(s.substr(charsIndex[a][j],i+1-charsIndex[a][j]))){
//cout<<s.substr(charsIndex[a][j],i+1-charsIndex[a][j]);
if(maxlength<i+1-charsIndex[a][j]){
maxlength=i+1-charsIndex[a][j];
maxstring=s.substr(charsIndex[a][j],i+1-charsIndex[a][j]);
}
}
}
charsIndex[a][j]=i;
}
if(maxstring=="")
return maxstring+s[0];
return maxstring;
}
};
int main()
{
string s;
cin>>s;
string res=Solution().longestPalindrome(s);
cout<<res;
}
03-22
1861
03-23
1854
01-29
1647