QOJ.ac

QOJ

时间限制: 3 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#17535. Russian Sushi

统计

Jinwoo is the world's greatest gambler and gourmet. Upon hearing that Dohyun, the owner of his favorite idol group, has opened a new restaurant called "Russian Conveyor Belt Sushi," he rushed over immediately.

The signature menu item is, naturally, Russian Conveyor Belt Sushi. When ordering this, a challenge is presented along with $N$ pieces of sushi; if the challenger succeeds, they do not have to pay. The goal of the challenge is to eat $K$ pieces of sushi without changing one's facial expression even once. The reason this challenge is difficult is that some pieces of sushi are packed with spicy wasabi!

The challenge proceeds as follows: First, Dohyun places $N$ pieces of sushi at regular intervals on a circular conveyor belt. In front of the challenger, Dohyun adds wasabi to some of the sushi so that their positions are known. All sushi, including the wasabi-filled ones, look identical and cannot be distinguished.

Next, the challenger is blindfolded, and Dohyun rotates the conveyor belt randomly. When the challenger opens their eyes, the conveyor belt begins to rotate clockwise. From this moment on, the challenger must eat each piece of sushi as it appears in front of them. That is, the challenger will eat consecutive pieces of sushi in a counter-clockwise direction, starting from the piece that is in front of them the moment they open their eyes.

To give more people a chance, Dohyun sells "sushi skip" coupons. The challenger can buy as many coupons as they want before being blindfolded. When the challenger uses a coupon, they can skip one piece of sushi in front of them without eating it. The skipped sushi is removed from the conveyor belt, and Dohyun checks it and informs the challenger whether it contained wasabi.

The challenger fails the challenge if they eat a wasabi-filled sushi and change their expression, or if they skip too many pieces of sushi and are unable to eat $K$ pieces.

Jinwoo intends to take on the Russian Conveyor Belt Sushi challenge. Unfortunately, Jinwoo cannot eat spicy food, so he must avoid the wasabi sushi. Since he does not want to lose his reputation as the world's greatest gambler and gourmet, he wants to purchase enough coupons to ensure that he never fails the challenge under any circumstances.

Given the positions of the wasabi sushi that Jinwoo observed before being blindfolded, what is the minimum number of coupons Jinwoo must purchase to guarantee success in the challenge using his best strategy?

Input

The first line contains the number of sushi $N$ and the number of sushi $K$ that must be eaten in the challenge, separated by a space. $(1 \le K \le N \le 200\,000)$

The second line contains a string of length $N$ consisting of the characters O and X. The $i$-th character indicates whether the $i$-th sushi in the counter-clockwise direction is a wasabi sushi. O represents a wasabi sushi, and X represents a sushi without wasabi.

Output

Output the minimum number of coupons Jinwoo must purchase to guarantee success in the challenge. If it is impossible to guarantee success regardless of how many coupons are purchased, output -1.

Examples

Input 1

6 2
OXXOXX

Output 1

3

Input 2

5 1
XXOXX

Output 2

-1

Input 3

4 4
XXXX

Output 3

0

Input 4

8 2
OXXOXXOX

Output 4

5

Input 5

8 1
XOXXOOXO

Output 5

6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.