Under construction

Still being built. Things may change

Special Dropkick 2

Time limit1sMemory limit1024 MB

Summary
Given a corridor string with obstacles, push obstacles at most M times, then find the minimum seconds to walk from zone 0 to zone N, breaking obstacles for 2 seconds each.
Level

Hard8 of 10

Topics
Dynamic programming, Greedy, Prefix sum
Solved
No attempts yet

Problem

The buildings in NLCS Jeju are flimsy, so walls and doors can be broken with a dropkick.

The corridor of NLCS Jeju is divided into square zones numbered 00 through NN. Each zone except zone 00, where Dongho stands, may contain an obstacle. Dongho wants to move from zone 00 to zone NN, where the classroom is, as quickly as possible.

Dongho has a string SS of length NN that describes the corridor. For each integer 1≤i≤N1\le i\le N, if SiS_i is X, zone ii has an obstacle. If SiS_i is ., zone ii has no obstacle.

Dongho can move obstacles at most MM times in the following ways.

  • Push an obstacle one cell toward higher numbers. All consecutive obstacles in the direction of higher numbers move together.
  • Push an obstacle one cell toward lower numbers. All consecutive obstacles in the direction of lower numbers move together.

After being pushed, the obstacles must still be within zones 11 through NN.

After moving obstacles at most MM times, Dongho reaches the classroom by combining two techniques.

  • Spend 1 second to move one zone toward higher numbers. Dongho cannot move into a zone that has an obstacle.
  • Spend 2 seconds to destroy an obstacle next to Dongho. Dongho can also destroy obstacles adjacent to the destroyed one. After destroying obstacles, Dongho moves to the position of a destroyed obstacle. If several were destroyed, Dongho can move to any of those positions.

Dongho wants to minimize the time to reach the classroom. Find how many seconds it takes to reach the classroom.

Input

The first line contains NN and MM, separated by a space.

The second line contains the string SS of length NN that describes the corridor. If SiS_i is X, zone ii has an obstacle. If SiS_i is ., zone ii has no obstacle.

Output

Print the number of seconds it takes Dongho to reach the classroom, as an integer.

Constraints

  • 1≤N≤200 0001 \le N \le 200\,000
  • 0≤M≤N0 \le M \le N

Examples1

  1. Example 1

    Input
    10 4
    .X..X..X..
    
    Expected output
    9