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;
long long mod = 1000000000 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  if (s.length() == 1) {
    cout << s;
    return 0;
  }
  vector<long long> dp1(26, 0);
  vector<vector<long long>> back(s.length(), dp1);
  back[s.length() - 1][s[s.length() - 1] - 'a'] = 1;
  for (long long i = s.length() - 2; i >= 0; i--) {
    for (long long j = 0; j < 26; j++) {
      back[i][j] = back[i + 1][j];
    }
    back[i][s[i] - 'a']++;
  }
  stack<long long> stk;
  string ans;
  for (long long i = 0; i < s.length(); i++) {
    stk.push(i);
    while (stk.size()) {
      long long f = 0;
      long long idx = s[stk.top()] - 'a';
      for (long long j = idx - 1; j >= 0; j--) {
        if (i + 1 < s.length() && back[i + 1][j] != 0) {
          f = 1;
          break;
        }
      }
      if (f == 0) {
        ans += s[stk.top()];
        stk.pop();
      } else
        break;
    }
  }
  while (stk.size() > 0) {
    ans += s[stk.top()];
    stk.pop();
  }
  cout << ans;
  return 0;
}
