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.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        // StringTokenizer st = new StringTokenizer(br.readLine());
        char[] ar = br.readLine().toCharArray();
        // int t = Integer.parseInt(st.nextToken());

        StringBuilder sb = new StringBuilder();

        char[] nse = new char[ar.length];

        char minChar = ar[ar.length - 1];
        nse[ar.length - 1] = minChar;

        for (int i = ar.length - 2; i >= 0; i--) {
            if (ar[i] > minChar) {
                nse[i] = minChar;
            } else {
                if (ar[i] < minChar) {
                    minChar = ar[i];
                }
                nse[i] = minChar;
            }
        }
        Stack<Character> st = new Stack<>();
        for (int i = 0; i < ar.length; i++) {
            if (!st.isEmpty()) {
                while (!st.isEmpty() && st.peek() <= nse[i]) {
                    sb.append(st.pop());
                }
            }
            st.push(ar[i]);
        }
        while (!st.isEmpty()) {
            sb.append(st.pop());
        }
        System.out.println(sb);
    }

    public static void swap(int[] ar, int i, int j) {
        int temp = ar[i];
        ar[i] = ar[j];
        ar[j] = temp;
    }

    public static class Pair {
        int x;
        int y;

        Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }
    }
}
