while 1: m=s='' for c in`input()`:s*=s[-1:]>=c;s+=c;m=max(m,s,key=len) print m