treasure

Time limit: 0.1s Memory limit: 64MB Input: Output:

Andrei is an adventurer who tries to find a treasure full of gold coins. When he arrives at the last clue, which will tell him where the treasure is, he sees that on the clue there are two numbers, NN and KK, and a string of NN lowercase English letters. Andrei should take the current string and should eliminate the first sequence of exactly KK identical letters which appear on consecutive positions. He will repeat this process until there will be no sequence which has KK consecutive identical letters.

Andrei asks you to solve this problem as soon as possible so that he will be the first who discovers the treasure.

Task

Find the final string after you successively eliminate the first sequence of KK identical letters which appear on consecutive positions, until there is no such sequence left.

Input data

The first line of the input contains two integers, NN, representing the number of characters of the string, and KK, representing the length of a sequence of identical characters.

The second line of the input contains the string of NN lowercase English letters.

Output data

The first line of the output contains a string of lowercase English letters, the string which will be obtained after all the possible eliminations are made.

Constraints and clarifications

  • 2KN200 0002 \leq K \leq N \leq 200 \ 000
  • The initial string contains only lowercase English letters.
  • It is guaranteed that the final string is not empty!
# Points Constraints
1 35 N,K1 000N, K \leq 1 \ 000
2 65 No additional constraints

Example 1

stdin

5 2
abbac

stdout

c

Explanation

The initial string: abbac\text{a\underline{bb}ac}.

The string after the first elimination: aac\text{\underline{aa}c}.

The string after the second elimination: c\text{c}.

Example 2

stdin

12 3
aabbbaabbaac

stdout

abbaac

Explanation

The initial string: aabbbaabbaac\text{aa\underline{bbb}aabbaac}.

The string after the first elimination: aaaabbaac\text{\underline{aaa}abbaac}.

The string after the second elimination: abbaac\text{abbaac}.

Log in or sign up to be able to send submissions!