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 INF = 1e18 + 1;
const long long MOD = 1e9 + 7;
const long double PI = 3.14159265358979323846264338;
const long long N = 1e5 + 1;
string second;
long long freq[26];
bool taken[N];
long long n;
string alpha = "abcdefghijklmnopqrstuvwxyz";
void solve() {
  cin >> second;
  n = second.size();
  second = "$" + second;
  for (long long i = 0; i < (long long)26; i++) freq[i] = 0;
  for (long long i = 1; i <= n; i++) {
    freq[second[i] - 'a']++;
  }
  string ans = "";
  stack<long long> st;
  string t = "";
  for (long long i = 1; i <= n; i++) {
    st.push(second[i] - 'a');
    freq[second[i] - 'a']--;
    long long mina = 27;
    for (long long j = 0; j < (long long)26; j++) {
      if (freq[j]) {
        mina = j;
        break;
      }
    }
    while (st.size() and st.top() <= mina) {
      ans += alpha[st.top()];
      st.pop();
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
