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;
vector<int> fillvec(int size) {
  vector<int> ans;
  for (int i = 0; i < size; i++) {
    int temp;
    cin >> temp;
    ans.push_back(temp);
  }
  return ans;
}
long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
vector<long long> getdivisors(long long n) {
  vector<long long> ans;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        ans.push_back(i);
      } else {
        ans.push_back(i);
        ans.push_back(n / i);
      }
    }
  }
  sort(ans.begin(), ans.end());
  return ans;
}
string DecToBin(int number) {
  if (number == 0) return "0";
  if (number == 1) return "1";
  if (number % 2 == 0)
    return DecToBin(number / 2) + "0";
  else
    return DecToBin(number / 2) + "1";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  char cl;
  string s;
  cin >> s;
  vector<int> ca(26);
  vector<char> t, u;
  for (int i = 0; i < s.size(); i++) ca[s[i] - 97]++;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < 26; j++)
      if (ca[j] != 0) {
        cl = j + 97;
        break;
      }
    while (!t.empty() && (t.back() <= cl)) {
      u.push_back(t.back());
      t.pop_back();
    }
    if (s[i] == cl) {
      ca[cl - 97]--;
      u.push_back(s[i]);
    } else {
      t.push_back(s[i]);
      ca[s[i] - 97]--;
    }
  }
  while (!t.empty()) {
    u.push_back(t.back());
    t.pop_back();
  }
  for (int i = 0; i < u.size(); i++) cout << u[i];
  cout << endl;
}
