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 alf[26] = {0};
bool smaller(int pos) {
  for (int i = 0; i < pos; i++) {
    if (alf[i] > 0) {
      return true;
    }
  }
  return false;
}
void run_case() {
  int count = 0;
  string s, t, u;
  string aux;
  t = u = "";
  cin >> s;
  for (auto var : s) {
    alf[var - 'a']++;
  }
  while (count < s.size() || !t.empty()) {
    if (t.empty() || smaller(t.back() - 'a')) {
      t.append(string(1, s[count]));
      alf[s[count] - 'a']--;
      count++;
    } else {
      u.append(string(1, t.back()));
      t.pop_back();
    }
  }
  cout << u << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  run_case();
}
