Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves:

  * Extract the first character of s and append t with this character. 
  * Extract the last character of t and append u with this character. 



Petya wants to get strings s and t empty and string u lexicographically minimal.

You should write a program that will help Petya win the game.

Input

First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.

Output

Print resulting string u.

Examples

Input

cab


Output

abc


Input

acdb


Output

abdc
base = ord('a')
char_list = [ord(char) - base for char in list(input())] # string converted to intiger list with a-z having value 0-25
min_string = ''
char_count = [0] * 26
stack = []

for x in char_list:
    char_count[x] += 1

cur_min_char = 0
for i in range(26):
    if char_count[i]:
        cur_min_char = i
        break
    
for x in char_list:
    if x == cur_min_char:
        min_string += chr(x + base)
        char_count[x] -= 1
        if char_count[x] == 0:
            cur_min_char = 0
            for i in range(26):
                if char_count[i]:
                    cur_min_char = i
                    break
            while stack and stack[-1] <= cur_min_char:
                min_string += chr(stack.pop() + base)
    else:
        stack.append(x)
        char_count[x] -= 1
while stack:
    min_string += chr(stack.pop() + base)
print(min_string)
