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.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

public class Task797C {
    public static void main(String[] args) throws IOException {
        InputScanner is = new InputScanner();
        String s = is.next();
        char[] input = s.toCharArray();
        int[] cnt = new int[26];
        for (int i = 0; i < input.length; i++) cnt[input[i] - 'a']++;
        Deque<Character> stack = new ArrayDeque<>();
        StringBuilder ans = new StringBuilder();
        int pos = 0;

        for (int c = 0; c < 26; c++) {
            while (!stack.isEmpty() && (stack.peek() - 'a') <= c) {
                ans.append(stack.pop());
            }

            for (; pos < input.length && cnt[c] > 0; pos++) {
                if (input[pos] - 'a' == c) {
                    ans.append(input[pos]);
                } else {
                    stack.push(input[pos]);
                }
                cnt[input[pos]-'a']--;
            }
        }

        while (!stack.isEmpty()) ans.append(stack.pop());
        System.out.println(ans);
    }

    static class InputScanner {
        BufferedReader br;
        StringTokenizer st;

        public InputScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (st == null || !st.hasMoreTokens()) {
                String line = br.readLine();
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            String next = next();
            return Integer.parseInt(next);
        }

        public long nextLong() throws IOException {
            String next = next();
            return Long.parseLong(next);
        }
    }
}
