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 int maxn = 100002;
char str[maxn];
int cnt[maxn][26];
char stk[maxn];
int n;
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < 26; j++) {
      cnt[i][j] = cnt[i + 1][j];
    }
    cnt[i][str[i] - 'a']++;
  }
  int cur = 1;
  int top = 0;
  while (cur <= n) {
    int key;
    if (!top)
      key = 26;
    else
      key = stk[top] - 'a';
    int c;
    for (c = 0; c < key; c++) {
      if (cnt[cur][c]) break;
    }
    if (c < key) {
      while (str[cur] - 'a' != c) {
        stk[++top] = str[cur++];
      }
      printf("%c", str[cur++]);
    } else {
      printf("%c", stk[top--]);
    }
  }
  while (top) {
    printf("%c", stk[top--]);
  }
  return 0;
}
