atcoder#ABC242B. [ABC242B] Minimize Ordering

[ABC242B] Minimize Ordering

Score : 200200 points

Problem Statement

You are given a string SS. Find the lexicographically smallest string SS' obtained by permuting the characters of SS.

Here, for different two strings s=s1s2sns = s_1 s_2 \ldots s_n and t=t1t2tmt = t_1 t_2 \ldots t_m, s<ts \lt t holds lexicographically when one of the conditions below is satisfied.

  • There is an integer i (1imin(n,m))i\ (1 \leq i \leq \min(n,m)) such that si<tis_i \lt t_i and sj=tjs_j=t_j for all integers j (1j<i)j\ (1 \leq j \lt i).
  • si=tis_i = t_i for all integers i (1imin(n,m))i\ (1 \leq i \leq \min(n,m)), and n<mn \lt m.

Constraints

  • SS is a string of length between 11 and 2×1052 \times 10^5 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

SS

Output

Print the lexicographically smallest string SS' obtained by permuting the characters in SS.

aba
aab

Three strings can be obtained by permuting aba:

  • aba
  • aab
  • baa

The lexicographically smallest among them is aab.

zzzz
zzzz