#K386. Lexicographically Smallest String

    ID: 26234 Type: Default 1000ms 256MiB

Lexicographically Smallest String

Lexicographically Smallest String

You are given a string \(S\) and an integer \(K\). You are allowed to perform the following operation any number of times:

  • Choose any substring of \(S\) of length \(K\) and rearrange its characters in any order.

Your task is to output the lexicographically smallest string that can be obtained by applying these operations. In other words, if we denote by \(T\) the resulting string, then for any other string \(T'\) obtainable by these operations, it must hold that \(T \leq T'\) in lexicographical order.

Note: In this problem, it turns out that the lexicographically smallest string can always be obtained by simply sorting all the characters of \(S\) in increasing order.

Formally, if you let \(S = s_1 s_2 \ldots s_n\), then the required answer is \(\text{sorted}(S)=t_1 t_2 \ldots t_n\), where \(t_1 \leq t_2 \leq \cdots \leq t_n\).

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains the string \(S\) consisting of lowercase English letters.
  • The second line contains the integer \(K\) \( (1 \leq K \leq 10^5) \).

outputFormat

Output to stdout a single line containing the lexicographically smallest string obtainable.

## sample
dcba
2
abcd

</p>