#K34602. Lexicographically Smallest String After K Operations

    ID: 25346 Type: Default 1000ms 256MiB

Lexicographically Smallest String After K Operations

Lexicographically Smallest String After K Operations

You are given a string s consisting of lowercase Latin letters and an integer k representing the number of operations. In each operation, you are allowed to choose any substring of s and sort the characters of that substring in non-decreasing order.

The goal is to obtain the lexicographically smallest string possible after exactly k operations. It turns out that an optimal strategy is to sort the entire string in one operation. Since sorting a substring (which can be the entire string) yields the sorted order of its characters, performing the operation on the full string will always produce the globally minimal arrangement. Hence, regardless of the value of k, the answer is simply the sorted version of s.

More formally, if we let the operation be denoted by a function op, then after one operation on s, the resulting string is:

\( sorted(s) = \text{sort}(s) \).

This holds because any substring can be chosen, and choosing the full string is optimal.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. A single line containing a string s consisting of lowercase Latin letters.
  2. A single line containing an integer k, the number of operations (which does not affect the outcome in the optimal strategy).

outputFormat

Print the lexicographically smallest string obtainable by performing exactly k operations (i.e. sorting the entire string).

The output is written to standard output (stdout).

## sample
dcba
2
abcd