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;
char s[100005];
int cnt[33], sum[33], bit[33];
stack<char> sta;
string ans = "";
int get(int x) {
  int res = 0;
  while (x >= 1) {
    res += bit[x];
    x -= x & (-x);
  }
  return res;
}
void add(int x) {
  while (x <= 26) {
    bit[x]++;
    x += x & (-x);
  }
}
int main() {
  scanf("%s", s + 1);
  for (int i = 1; s[i]; ++i) cnt[s[i] - 'a']++;
  for (int i = 2; i <= 26; ++i) sum[i] = sum[i - 1] + cnt[i - 2];
  for (int i = 1; s[i]; ++i) {
    sta.push(s[i]);
    add(s[i] - 'a' + 1);
    while (!sta.empty() && get(sta.top() - 'a') == sum[sta.top() - 'a' + 1])
      ans += sta.top(), sta.pop();
  }
  while (!sta.empty()) ans += sta.top(), sta.pop();
  cout << ans << endl;
  return 0;
}
