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 long long MOD = (long long)1e9 + 7;
const int SIZE = 2e5 + 5;
const long long INF = 1LL << 60;
const double eps = 1e-4;
const double PI = 3.1415926535897932;
int last[26];
int main() {
  string s;
  cin >> s;
  int n = ((int)(s).size());
  for (int i = 0; i < (26); ++i) last[i] = -1;
  for (int i = 0; i < (n); ++i) last[s[i] - 'a'] = i;
  int cl = 0;
  stack<int> st;
  string ans = "";
  for (int i = 0; i < (n); ++i) {
    while (cl < 26 && last[cl] < i) {
      while (((int)(st).size()) && (st.top() <= cl)) {
        ans += 'a' + st.top();
        st.pop();
      }
      cl++;
    }
    if (cl >= 26) break;
    while (((int)(st).size()) && (st.top() <= cl)) {
      ans += 'a' + st.top();
      st.pop();
    }
    if (last[cl] > i) {
      if (s[i] == 'a' + cl) {
        ans += s[i];
      } else {
        st.push(s[i] - 'a');
      }
    } else if (last[cl] == i) {
      ans += s[i];
      cl++;
    }
  }
  while (((int)(st).size())) {
    int i = st.top();
    st.pop();
    ans += 'a' + i;
  }
  cout << ans;
}
