{"problem":{"name":"XYYYX","description":{"content":"You are given a string $S$ of length $N$ consisting of `X` and `Y`. You will choose $K$ characters at distinct positions in $S$ and change each of them: `X` becomes `Y` and `Y` becomes `X`. Find the m","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc157_b"},"statements":[{"statement_type":"Markdown","content":"You are given a string $S$ of length $N$ consisting of `X` and `Y`. You will choose $K$ characters at distinct positions in $S$ and change each of them: `X` becomes `Y` and `Y` becomes `X`. Find the maximum possible number of pairs of consecutive `Y`s in the resulting string.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $0 \\leq K \\leq N$\n*   $S$ is a string of length $N$ consisting of `X` and `Y`.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $K$\n$S$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc157_b","tags":[],"sample_group":[["5 1\nXYXYX","2\n\nYou will choose one character.\n\n*   If you choose the $1$\\-st character, the resulting string is `YYXYX`, with one pair of consecutive `Y`s at positions $1, 2$.\n*   If you choose the $2$\\-nd character, the resulting string is `XXXYX`, with no pair of consecutive `Y`s.\n*   If you choose the $3$\\-rd character, the resulting string is `XYYYX`, with two pairs of consecutive `Y`s at positions $2, 3$ and $3, 4$.\n*   If you choose the $4$\\-th character, the resulting string is `XYXXX`, with no pair of consecutive `Y`s.\n*   If you choose the $5$\\-th character, the resulting string is `XYXYY`, with one pair of consecutive `Y`s at positions $4, 5$.\n\nThus, the sought maximum number is $2$."],["5 4\nXYXYX","2\n\nIt is optimal to choose the $1$\\-st, $2$\\-nd, $3$\\-rd, and $5$\\-th characters to get `YXYYY`, or choose the $1$\\-st, $3$\\-rd, $4$\\-th, and $5$\\-th characters to get `YYYXY`. Note that you may not choose a character at the same position multiple times."]],"created_at":"2026-03-03 11:01:14"}}