#ARC157B. [ARC157B] XYYYX

[ARC157B] XYYYX

Score : 500500 points

Problem Statement

You are given a string SS of length NN consisting of X and Y. You will choose KK characters at distinct positions in SS and change each of them: X becomes Y and Y becomes X. Find the maximum possible number of pairs of consecutive Ys in the resulting string.

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 0KN0 \leq K \leq N
  • SS is a string of length NN consisting of X and Y.

Input

The input is given from Standard Input in the following format:

NN KK

SS

Output

Print the maximum possible number of pairs of consecutive Ys in the resulting string.

5 1
XYXYX
2

You will choose one character.

  • If you choose the 11-st character, the resulting string is YYXYX, with one pair of consecutive Ys at positions 1,21, 2.
  • If you choose the 22-nd character, the resulting string is XXXYX, with no pair of consecutive Ys.
  • If you choose the 33-rd character, the resulting string is XYYYX, with two pairs of consecutive Ys at positions 2,32, 3 and 3,43, 4.
  • If you choose the 44-th character, the resulting string is XYXXX, with no pair of consecutive Ys.
  • If you choose the 55-th character, the resulting string is XYXYY, with one pair of consecutive Ys at positions 4,54, 5.

Thus, the sought maximum number is 22.

5 4
XYXYX
2

It is optimal to choose the 11-st, 22-nd, 33-rd, and 55-th characters to get YXYYY, or choose the 11-st, 33-rd, 44-th, and 55-th characters to get YYYXY. Note that you may not choose a character at the same position multiple times.