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 oo = 1e9 + 7;
const int maxn = 1e5 + 7;
string s;
int n, Last[500], le, ri;
char a[maxn], b[maxn];
string res;
inline void read(int &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline void writeln(long long x) {
  char buffor[21];
  register int i = 0;
  int neg = 0;
  if (x < 0) {
    neg = 1;
    x = -x;
  }
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
void nhap() {
  cin >> s;
  n = s.size();
  s = '~' + s;
  for (int i = (1), _b = (n); i <= _b; ++i) Last[s[i]] = i;
  b[n] = s[n];
  for (int i = (n - 1), _b = (1); i >= _b; --i) b[i] = min(s[i], b[i + 1]);
}
void solve() {
  ri = 1;
  while (1) {
    while (le && (ri == n + 1 || a[le] <= b[ri])) {
      res += a[le--];
    }
    if (le == 0 && ri == n + 1) break;
    for (int i = (ri), _b = (Last[b[ri]]); i <= _b; ++i)
      if (s[i] == b[ri])
        res += s[i];
      else
        a[++le] = s[i];
    ri = Last[b[ri]] + 1;
  }
}
void print() { cout << res; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  nhap();
  solve();
  print();
}
