cho.sh
Notes
Loading...

Prefix Reversal 3

Time limit

2s

Memory limit

128 MB

Problem

You are given a string S of length N. For each integer i from 1 through N, in that order, you may choose whether to reverse exactly the first i characters of the current string.

After all choices have been made, output the lexicographically smallest string that can be obtained.

Input

The first line contains the string S.

The length of S is at most 50, and every character is an uppercase English letter.

Output

Print the lexicographically smallest obtainable string.