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
s = input()
s = s[-1::-1]
l = [s[0]]
for i in range(1,len(s)):
    l.append(min(s[i],l[-1]))
s = s[-1::-1]
l = l[-1::-1]
st = []
p1 = 0
ans = []

while len(ans)!=len(s):
    # print(st,ans,sep="**")
    if p1+1<len(l) and l[p1+1]<s[p1]:
        if len(st)!=0 and l[p1+1] >= st[-1]:
            ans.append(st[-1])
            st.__delitem__(len(st)-1)
        else:
            st.append(s[p1])
            p1 += 1
    else:
        if len(st)==0:
            ans.append(s[p1])
            p1 += 1
        elif p1==len(l):
            ans.append(st[-1])
            st.__delitem__(len(st)-1)
        else:
            if s[p1] < st[-1]:
                ans.append(s[p1])
                p1 += 1
            else:
                ans.append(st[-1])
                st.__delitem__(len(st)-1)
print(*ans,sep="")
