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
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class MinimalString {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder s = new StringBuilder(scanner.nextLine());
        Deque<Character> t = new ArrayDeque<>();
        StringBuilder u = new StringBuilder();
        int[] count = new int[26];
        for (char current : s.toString().toCharArray()) {
            count[current - 'a']++;
        }
//        System.out.println(Arrays.toString(count));

        while (s.length() > 0) {
            char currChar = s.charAt(0);
            s.deleteCharAt(0);
            count[currChar - 'a']--;
            t.addFirst(currChar);

            boolean stringHasSmaller = false;
            while (!t.isEmpty() && !stringHasSmaller) {
                for (int i = 0; i < count.length; i++) {
                    if (count[i] != 0 && (i + 'a') < t.peekFirst()) {
                        stringHasSmaller = true;
                        break;
                    }
                }

                if (!stringHasSmaller) {
                    u.append(t.removeFirst());
                }
            }
        }

        // add to u if remaining elements
        while (!t.isEmpty()) {
            u.append(t.removeFirst());
        }

        System.out.println(u.toString());
        scanner.close();
    }
}
