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 len;
char s[100005];
stack<int> st;
char ans[100005];
int las[100005];
int main() {
  cin >> s;
  len = strlen(s);
  if (len == 1) {
    cout << s << endl;
    return 0;
  }
  int now = 1;
  st.push(s[0]);
  las[len - 1] = s[len - 1] - 'a';
  for (int i = len - 2; i >= 0; i--) {
    las[i] = min(las[i + 1], s[i] - 'a');
  }
  int cnt = 0;
  while (1) {
    if (now == len) break;
    if (st.empty()) {
      st.push(s[now++]);
    } else if (las[now] < st.top() - 'a') {
      st.push(s[now++]);
    } else {
      ans[cnt++] = st.top();
      st.pop();
    }
  }
  while (!st.empty()) {
    ans[cnt++] = st.top();
    st.pop();
  }
  ans[cnt] = 0;
  cout << ans << endl;
  return 0;
}
