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>
char stack[1000010];
int stptr = -1;
void push(char val) {
  stack[++stptr] = val;
  return;
}
char pop() {
  if (stptr == -1) return -1;
  return stack[stptr--];
}
char top() {
  if (stptr == -1) return -1;
  return stack[stptr];
}
int main() {
  int n;
  char str[100010];
  char output[100010];
  char minchar[100010];
  scanf(" %s", str);
  n = strlen(str);
  int freq[27];
  for (int i = 0; i < n; i++) {
    freq[str[i] - 'a']++;
  }
  char min = 'z' + 1;
  for (int i = n - 1; i >= 0; i--) {
    if (str[i] < min) {
      min = str[i];
    }
    minchar[i] = min;
  }
  int val = 0;
  while (freq[val] == 0 && val < 26) {
    val++;
  }
  int p = 0, op = 0;
  while (p < n) {
    if (top() != -1 && val + 'a' >= top()) {
      output[op++] = pop();
      freq[val]--;
      while (freq[val] == 0) {
        val++;
      }
      if (minchar[p] != val + 'a') {
        val = minchar[p] - 'a';
      }
      continue;
    }
    while (p < n && str[p] != val + 'a') {
      push(str[p]);
      p++;
    }
    if (p == n) {
      break;
    }
    output[op++] = str[p];
    freq[val]--;
    while (freq[val] == 0) {
      val++;
    }
    p++;
    if (minchar[p] != val + 'a') {
      val = minchar[p] - 'a';
    }
  }
  while (top() != -1) {
    output[op++] = pop();
  }
  output[op] = '\0';
  printf("%s\n", output);
  return 0;
}
