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.*;

public class Codeforces {
    private static void solve(String s) {
        Stack<Integer> stack = new Stack<>();
        int n = s.length();
        int[] a = new int[n+1];
        a[1]=s.charAt(n-1)-'a';
        for (int i = n-2; i >=0 ; i--) {
            a[n-i]=Math.min(s.charAt(i)-'a',a[n-i-1]);
        }
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < n; i++) {
            while (!stack.isEmpty()&&stack.peek()<=a[n-i]){
                ans.append((char)(stack.pop()+'a'));
            }
            stack.push(s.charAt(i)-'a');
        }
        while (!stack.isEmpty()){
            ans.append((char)(stack.pop()+'a'));
        }
        System.out.println(ans.toString());
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
       solve(sc.next());
    }

    private static class Edge{
        int v;
        int w;

        public Edge(int v, int w) {
            this.v = v;
            this.w = w;
        }
    }


    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long[] readArrayLong(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        int[] readArrayInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}