class Solution {
fun palindrome(s: String, l: Int, r: Int) : Boolean {
var u = l
var v = r-1
while (u < v)
if (s[u++] != s[v--])
return false
return true }
fun longestPalindrome(s: String): String {
val n = s.length
for (k in n downTo 2)
for (l in 0 until n-k+1)
if (palindrome(s,l,l+k))
return s.substring(l,l+k)
return s.substring(0,1) } }
fun main(args: Array<String>) {
print(Solution().longestPalindrome(readLine()!!)) }
Y2xhc3MgU29sdXRpb24gewogICAgZnVuIHBhbGluZHJvbWUoczogU3RyaW5nLCBsOiBJbnQsIHI6IEludCkgOiBCb29sZWFuIHsKICAgICAgICB2YXIgdSA9IGwKICAgICAgICB2YXIgdiA9IHItMQogICAgICAgIHdoaWxlICh1IDwgdikKICAgICAgICAgICAgaWYgKHNbdSsrXSAhPSBzW3YtLV0pCiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2UgCiAgICAgICAgcmV0dXJuIHRydWUgfQogICAgZnVuIGxvbmdlc3RQYWxpbmRyb21lKHM6IFN0cmluZyk6IFN0cmluZyB7CiAgICAgICAgdmFsIG4gPSBzLmxlbmd0aAogICAgICAgIGZvciAoayBpbiBuIGRvd25UbyAyKSAKICAgICAgICAgICAgZm9yIChsIGluIDAgdW50aWwgbi1rKzEpIAogICAgICAgICAgICAgICAgaWYgKHBhbGluZHJvbWUocyxsLGwraykpCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHMuc3Vic3RyaW5nKGwsbCtrKQogICAgICAgIHJldHVybiBzLnN1YnN0cmluZygwLDEpIH0gfQogICAgICAgIApmdW4gbWFpbihhcmdzOiBBcnJheTxTdHJpbmc+KSB7CiAgICBwcmludChTb2x1dGlvbigpLmxvbmdlc3RQYWxpbmRyb21lKHJlYWRMaW5lKCkhISkpIH0=