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.*;
import java.math.*;
 
public class Edu19Q3
{
    public static void main(String[] args) throws IOException
    {
        FastScanner obj = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
      	String str = obj.next();
      	int n = str.length();
      	
      	char[] min = new char[n];
      	char[] arr = str.toCharArray();
      	
      	min[n-1] = arr[n-1];
      	for(int i=n-2 ; i>=0; i--)
      		min[i]  = (char)Math.min(arr[i],min[i+1]);
		Stack<Character> stack = new Stack<>();
      	StringBuilder ans = new StringBuilder("");
      	for(int  i=0;i<n;i++)
      	{
      		if(stack.isEmpty() || min[i] < stack.peek())
      			stack.push(arr[i]);
      		else
      		{
      			i--;
      			ans.append(stack.pop());
      		}
      	}
      	while(!stack.isEmpty())
      		ans.append(stack.pop());
      	out.println(ans);
        out.close();
   }
   

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------FastScanner class for faster input----------
   public static class FastScanner {
        BufferedReader br;
        StringTokenizer tokenizer;
 
        public FastScanner() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = new StringTokenizer(br.readLine().trim());
        }
 
        String next() {
            while (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                    }
            }
          return tokenizer.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
      
        int[] nextIntArray() throws IOException {
            String[] line = br.readLine().trim().split(" ");
            int[] out = new int[line.length];
            
            for (int i = 0; i < line.length; i++) {
                out[i] = Integer.valueOf(line[i]);
            }
            return out;
        }
        
        BigInteger nextBigInteger() throws IOException {
            return new BigInteger(next());
        }
        
        String nextLine(){
            String str = "";
	        try {
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
        }

   }
   //--------------------------------------------------------
}