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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep  1 11:24:03 2018

@author: all_blue
"""

s = [char for char in input().strip()]
alpha_dict ={}

for alpha in "qwertyuiopasdfghjklzxcvbnm":
    alpha_dict[alpha] = 0

for char in s:
    alpha_dict[char] += 1

t = []
u = []

for char in s:
    t.append(char)
    alpha_dict[char] -= 1
    while t:
        top = t[-1]
        smaller_found = False
        for alpha in alpha_dict:
            if alpha < top and alpha_dict[alpha] > 0:
                smaller_found = True
                break
        if smaller_found:
            break
        else:
            u.append(t.pop())
    
while t:
    u.append(t.pop())
    
print(*u, sep = "")
