#P10368. Elimination Operations on a String

    ID: 12373 Type: Default 1000ms 256MiB

Elimination Operations on a String

Elimination Operations on a String

Given a string A of length \(n\). A character \(A_i\) (where \(1 < i < n\)) is called eliminable if \(A_{i-1} = A_{i+1}\) (in \(\LaTeX\) format: \(A_{i-1}=A_{i+1}\)).

Define one operation as eliminating all eliminable characters in the string simultaneously, i.e. remove every character \(A_i\) (for \(1 < i < n\)) which satisfies \(A_{i-1}=A_{i+1}\). The remaining characters retain their order. Note that after each operation the string becomes shorter and indices are recomputed.

Your task is to output the string after performing \(k\) operations.

inputFormat

The input consists of two lines. The first line contains the string A. The second line contains an integer \(k\), the number of operations to perform.

outputFormat

Output the resulting string after performing \(k\) elimination operations.

sample

abcd
1
abcd