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;
int main() {
  string s, u;
  vector<char> t;
  cin >> s;
  int i, j, prev = 0;
  vector<int> v(27, -1);
  for (i = 0; i < s.length(); ++i) {
    int x = s[i] - 'a';
    v[x] = i;
  }
  i = 0;
  j = 0;
  while (true) {
    while (i < 26 && v[i] < prev && v[i] == -1) i++;
    prev = v[i];
    if (i == 26)
      break;
    else {
      int x = t.size() - 1;
      while (x >= 0 && t[x] - 'a' <= i) {
        u += t[x];
        t.pop_back();
        x--;
      }
      while (j <= v[i]) {
        x = s[j] - 'a';
        if (x == i)
          u += s[j];
        else
          t.push_back(s[j]);
        j++;
      }
      i++;
    }
  }
  reverse(t.begin(), t.end());
  cout << u;
  for (i = 0; i < t.size(); ++i) {
    cout << t[i];
  }
  return 0;
}
