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.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ListIterator;
import java.util.Scanner;
   
public class test1 {
	
	
	
	public static void main(String[] args) {
		

		//Scanner sc = new Scanner (System.in);
	//System.out.println("enter");
		
	InputReader sc = new InputReader(System.in);
	PrintWriter w = new PrintWriter(System.out);
	
	String s = sc.readString();
	Stack <Character > t = new Stack ();
	int i ;
	StringBuffer u =new StringBuffer(""); 
	int a[]  = new int [26];
	
	
	int k=0;
	for(i=0 ;i<s.length();i++)
	{
		a[s.charAt(i)-97]++;
	}
	int j;
	boolean valid = true ;
	for(i= 0 ;i<s.length();i++)
	{
		t.push(s.charAt(i));
		
		a[s.charAt(i)-97]--;
		valid = true ;
		
		while (valid && !t.isEmpty())
		{
			for (j=0  ; j<(t.peek()-97);j++)
			{
				if(a[j] >0)
				{
					valid = false ;
					break;
				}
				
			}
			if (valid)
			u.append(t.pop());
			else
				break;
		}
		
		
		
		
	}
	while(!t.isEmpty())
	{
		u.append(t.pop());
	}
	w.println(u);
		w.close();

}
}
 
class InputReader {
	 
	private final InputStream st;
	private final byte[] buf = new byte[8192];
	private int cc, sc;
	private SpaceCharFilter f;
 
	public InputReader(InputStream st) {
		this.st = st;
	}
 
	public int t() {
		if (sc == -1)
			throw new InputMismatchException();
		if (cc >= sc) {
			cc = 0;
			try {
				sc = st.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (sc <= 0)
				return -1;
		}
		return buf[cc++];
	}
 
	public int nextInt() {
		int c = t();
		while (isSpaceChar(c)) {
			c = t();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = t();
		}
		int res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = t();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
 
	public long nextLong() {
		int c = t();
		while (isSpaceChar(c)) {
			c = t();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = t();
		}
		long res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = t();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
 
	public int[] nextIntArray(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
 
	public String readString() {
		int c = t();
		while (isSpaceChar(c)) {
			c = t();
		}
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = t();
		} while (!isSpaceChar(c));
		return res.toString();
	}
 
	public String nextLine() {
		int c = t();
		while (isSpaceChar(c))
			c = t();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = t();
		} while (!isEndOfLine(c));
		return res.toString();
	}
 
	public boolean isSpaceChar(int c) {
		if (f != null)
			return f.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
 
	private boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}
 
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}   