def f(i, j, side)
	return "" if side.size * 2 + (j-i+1) < $max
	return side + $a[i] + side.reverse if i == j
	return side + side.reverse if j < i
	cache = $memo[[i, j]]
	return side + cache + side.reverse if cache
	
	if $a[i] == $a[j]
		return f(i+1, j-1, side + $a[i])	
	end

	x = f(i+1, j, side)
	y = f(i, j-1, side)
	ans = (x.size > y.size ? x : y)
	$max = ans.size if ans.size > $max
	$memo[[i, j]] = ans[side.size..-side.size-1]
	ans
end

def f(i, j, side)
	return "" if side.size * 2 + (j-i+1) < $max
	return side + $a[i] + side.reverse if i == j
	return side + side.reverse if j < i
	cache = $memo[[i, j]]
	return side + cache + side.reverse if cache
	
	if $a[i] == $a[j]
		return f(i+1, j-1, side + $a[i])	
	end

	hash = {}
	ans = nil
	j.downto(i){|k|
		next if hash[$a[k]]
		hash[$a[k]] = 1
		l = $first[i][$a[k]]
		x = f(l, k, side)
		ans = x if !ans || x.size > ans.size
	}

	$max = ans.size if ans.size > $max
	$memo[[i, j]] = ans[side.size..-side.size-1]
	ans
end

while gets
	$a = $_.chomp.split("")
	$first = (0..$a.size-1).map{|i|
		hash = {}
		(i..$a.size-1).each{|j|
			hash[$a[j]] ||= j
		}
		hash
	}
	$max = 0
	$memo = {}
	puts f(0, $a.size-1, "")
end