#!/usr/bin/perl
# Created by Ben Okopnik on Thu Oct 17 09:25:20 EDT 2002

sub repeated_substring {
	$str = shift;
	$strlen = length $str;
	$longest = "";
	
	return "" unless $str =~ /(.).*\1/;
	$off = 0;
	$len = 1;
	
	{
		$match = substr $str, $off, $len;
		if ( ( substr $str, $off + $len ) =~ /\Q$match\E/ ){
			$longest = $match;
			return $longest if ( $off + $len * 2 + 2 ) > $strlen;
			$len++;
		}
		else{
			return $longest if ( $off + $len * 2 + 1 ) > $strlen;
			$off++;
		}
		redo;
	}
}

{
	local $/;
	( $string = <> ) =~ s/\n//g;
}

print repeated_substring $string
