main(i,v){char*s=gets(v),c=*s;while(i=*++s)while(i&&putchar(c)-*s)i=*s-(c+=c<*s?1:-1);puts(s-1);}