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 M = (int)1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  vector<int> suff((int)s.size());
  vector<int> f(26, -1);
  for (int i = (int)s.size() - 1; i >= 0; --i) {
    f[s[i] - 'a'] = i;
    for (int j = 0; j < 26; ++j) {
      if (f[j] != -1) {
        suff[i] = f[j];
        break;
      }
    }
  }
  stack<char> st;
  int index = -1;
  string res = "";
  while (1) {
    char x;
    int ind;
    if (index + 1 < (int)s.size()) {
      x = s[suff[index + 1]];
      ind = suff[index + 1];
    } else {
      x = 'z' + 1;
      ind = index + 1;
    }
    while (!st.empty()) {
      char top = st.top();
      if (top > x)
        break;
      else {
        st.pop();
        res.push_back(top);
      }
    }
    if (ind < (int)s.size()) res.push_back(x);
    for (int j = index + 1; j < ind; ++j) {
      st.push(s[j]);
    }
    if (ind == (int)s.size() && st.empty()) break;
    index = ind;
  }
  cout << res << "\n";
}
