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
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
int N, idx = 0;
stack<int> stck;
char S[MAXN], ans[MAXN];
int best[MAXN];
int main() {
  scanf("%s", S);
  N = strlen(S);
  best[N - 1] = N - 1;
  for (int i = N - 2; i > (int)-1; i--)
    best[i] = S[i] <= S[best[i + 1]] ? i : best[i + 1];
  for (int i = 0; i < (int)N; i++) {
    if (idx < N && !stck.empty()) {
      int j = stck.top();
      if (S[j] <= S[best[idx]]) {
        ans[i] = S[j];
        stck.pop();
      } else {
        for (int j = idx; j < (int)best[idx]; j++) stck.push(j);
        ans[i] = S[best[idx]];
        idx = best[idx] + 1;
      }
    } else if (idx < N) {
      for (int j = idx; j < (int)best[idx]; j++) stck.push(j);
      ans[i] = S[best[idx]];
      idx = best[idx] + 1;
    } else {
      int j = stck.top();
      ans[i] = S[j];
      stck.pop();
    }
  }
  printf("%s\n", ans);
}
