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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Stack;

public class app {
	public static void main(String args[]) {
		InputReader sc = new InputReader(System.in);
		PrintWriter in = new PrintWriter(System.out);
        String s = sc.readString();
		StringBuilder u = new StringBuilder();
        Stack<Character> t = new Stack<Character>();
        int a[] = new int[26];
        int i;
        for(i=0; i<s.length(); i++) 
        	a[s.charAt(i)-97]++;
        
        for(i=0; i<s.length(); i++) {
        	t.push(s.charAt(i));
        	a[s.charAt(i)-97]--;
        	boolean check = true;
        	while(!t.empty() && check) {
        		char top = t.peek();
        		for(int j=0; j<top-97; j++) {
        			if(a[j]>0) {
        				check=false;
        				break;
        			}
        		}
        		if(check)
        			u.append(t.pop());
        	}
        }
        while(!t.empty()) 
        	u.append(t.pop());
        in.println(u);   
		in.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);
	}
}