103791: [Atcoder]ABC379 B - Strawberries

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:15 Solved:0

Description

Score : $200$ points

Problem Statement

Takahashi has $N$ teeth arranged in a single row from left to right. The current condition of his teeth is represented by a string $S$.

If the $i$-th character of $S$ is O, it means that the $i$-th tooth from the left is healthy. If it is X, it means that the $i$-th tooth has a cavity. Healthy teeth do not have cavities.

When he has $K$ consecutive healthy teeth, he can eat one strawberry using those $K$ teeth. After eating a strawberry, those $K$ teeth develop cavities and become unhealthy.

Find the maximum number of strawberries he can eat.

Constraints

  • $1 \leq K \leq N \leq 100$
  • $N$ and $K$ are integers.
  • $S$ is a string of length $N$ consisting of O and X.

Input

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

$N$ $K$
$S$

Output

Print the answer.


Sample Input 1

7 3
OOXOOOO

Sample Output 1

1

He can eat one strawberry by using the three consecutive healthy teeth from the 4th to 6th tooth from the left. After this, he cannot eat any more strawberries. Besides, there is no way for him to eat more than one strawberry. Therefore, print $1$.


Sample Input 2

12 2
OXXOOOXOOOOX

Sample Output 2

3

Sample Input 3

22 5
XXOOOOOOOOXXOOOOOXXXXX

Sample Output 3

2

Output

得分:200分

问题陈述

高桥有N颗牙齿按从左到右排列成一行。他的牙齿当前状况用一个字符串S表示。

如果S的第i个字符是O,那么意味着从左边数第i颗牙齿是健康的。如果是X,则意味着第i颗牙齿有蛀牙。健康的牙齿没有蛀牙。

当他有K颗连续的健康牙齿时,他可以用这K颗牙齿吃一个草莓。吃完草莓后,这K颗牙齿会得蛀牙并变得不健康。

找出他最多可以吃多少个草莓。

约束条件

  • $1 \leq K \leq N \leq 100$
  • N和K都是整数。
  • S是由OX组成的长度为N的字符串。

输入

输入从标准输入以下格式给出:

$N$ $K$
$S$

输出

打印答案。


示例输入1

7 3
OOXOOOO

示例输出1

1

他可以用从左边数第4颗到第6颗的三颗连续健康牙齿吃一个草莓。之后,他不能再吃更多的草莓。而且,他没有办法吃超过一个草莓。因此,打印$1$。


示例输入2

12 2
OXXOOOXOOOOX

示例输出2

3

示例输入3

22 5
XXOOOOOOOOXXOOOOOXXXXX

示例输出3

2

加入题单

上一题 下一题 算法标签: