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
def lessnotpresent(each,d):
    for key, value in list(d.items()):
        if key < each and d[key] > 0:
            return False
    return True

from collections import defaultdict

s = list(input())
t = []
d = defaultdict(int)
u = []

for each in s:
    d[each] += 1
    
for each in s:   
    t.append(each)
    d[each] -= 1
    
    while len(t) and lessnotpresent(t[-1], d):
        
        temp = t.pop()  
        u.append( temp )
        
    
print("".join(u+t[::-1]))