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.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Stack;
import java.util.StringTokenizer;

public class Prob3 {
	
	private void solve(InputReader in, PrintWriter out) {
		char[] s = in.next().toCharArray();
		int[] a = new int[26];
		for (char c: s) {
			a[c-'a']++;
		}
		int smallest = -1;
		while(a[++smallest] == 0);
		Stack<Character> t = new Stack<>();
		char[] result = new char[s.length];
		int older = 0, newer = 0;
		for (int i = 0; i < s.length; i++) {
			while (t.isEmpty() || (t.peek()-'a' > smallest)) {
				if (older == s.length) break;
				t.push(s[older++]);
				a[t.peek()-'a']--;
			}
			while (smallest < 26 && a[smallest] == 0) {
				smallest++;
			}
			result[newer++] = t.pop();
		}
		System.out.println(new String(result));
	}

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Prob3 solver = new Prob3();
		solver.solve(in, out);
		out.close();
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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

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