while 1:s=raw_input();r=range(99);print max([s[i:j]*(s[i:j]in s[i+1:])for i in r for j in r],key=len)