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.*;
import java.util.*;

public class test {
    
    void solve(InputReader in, PrintWriter out) throws IOException {
        char[] s = in.next().toCharArray();
        Stack<Character> stack = new Stack<>();
        int[] c = new int[26];
        for(int i=0; i<s.length; i++) {
            c[s[i]-'a']++;
        }
        for(int i=0; i<s.length;) {
            if(stack.size()>0) {
                char t = stack.peek();
                for(int j=0; j<c.length; j++) {
                    if(c[j]!=0) {
                        if(j+'a'<=t) {
                            t = (char)(j+'a');
                        }
                        break;
                    }
                }
                if(t==stack.peek()) {
                    stack.pop();
                    out.print(t);
                } else {
                    while(i<s.length && s[i]!=t) {
                        stack.push(s[i]);
                        c[s[i]-'a']--;
                        i++;
                    }
                    out.print(t);
                    c[t-'a']--;
                    i++;
                }
            } else {
                stack.push(s[i]);
                c[s[i]-'a']--;
                i++;
            }
        }
        while(stack.size()>0) {
            char x = stack.pop();
            out.print(x);
        }
        out.println();
    }
    
    
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        new test().solve(in, out);
        out.close();
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    }
    
}