

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 100 点
問題文
N 個の箱が横一列に並んでおり、そのうちのいくつかの箱にはクッキーが入っています。
各箱の状態は長さ N の文字列 S によって表されます。
具体的には、左から i\ (1\leq i\leq N) 番目の箱は、S の i 文字目が @
のときクッキーが 1 枚入っており、.
のとき空き箱です。
高橋君は今からの D 日間、一日一回ずつ、これらの箱のいずれかに入ったクッキーを 1 枚選んで食べます。
N 個の箱のうち、D 日間が経過した後に空き箱であるものはいくつあるか求めてください。 (この値は高橋君が各日でどのクッキーを選ぶかによらないことが証明できます。)
なお、S には @
が D 個以上含まれることが保証されます。
制約
- 1\leq D \leq N \leq 100
- N,D は整数
- S は
@
と.
からなる長さ N の文字列 - S には
@
が D 個以上含まれる
入力
入力は以下の形式で標準入力から与えられる。
N D S
出力
N 個の箱のうち、D 日間が経過した後に空き箱であるものの個数を出力せよ。
入力例 1
5 2 .@@.@
出力例 1
4
例えば、高橋君は以下のように行動する可能性があります。
- 1 日目:左から 2,3,5 番目の箱にクッキーが入っている。左から 2 番目の箱に入っているクッキーを選んで食べる。
- 2 日目:左から 3,5 番目の箱にクッキーが入っている。左から 5 番目の箱に入っているクッキーを選んで食べる。
- 2 日間が経過した後、左から 3 番目の箱にのみクッキーが入っている。よって、5 個の箱のうち 4 箱が空き箱である。
高橋君が各日で選ぶクッキーはこの例とは異なる可能性もありますが、いずれにせよ 2 日間が経過した後には 4 箱が空き箱です。 よって答えは 4 です。
入力例 2
3 3 @@@
出力例 2
3
入力例 3
10 4 @@@.@@.@@.
出力例 3
7
Score: 100 points
Problem Statement
There are N boxes arranged in a row, and some of these boxes contain cookies.
The state of these boxes is represented by a string S of length N.
Specifically, the i-th box (1\leq i \leq N) from the left contains one cookie if the i-th character of S is @
, and is empty if it is .
.
Over the next D days, Takahashi will choose and eat one cookie per day from among the cookies in these boxes.
Determine how many of the N boxes will be empty after D days have passed. (It can be proved that this value does not depend on which cookies Takahashi chooses each day.)
It is guaranteed that S contains at least D occurrences of @
.
Constraints
- 1 \leq D \leq N \leq 100
- N and D are integers.
- S is a string of length N consisting of
@
and.
. - S contains at least D occurrences of
@
.
Input
The input is given from Standard Input in the following format:
N D S
Output
Print the number of boxes that will be empty after D days have passed among the N boxes.
Sample Input 1
5 2 .@@.@
Sample Output 1
4
For example, Takahashi might act as follows:
- Day 1: There are cookies in the 2nd, 3rd, and 5th boxes from the left. He chooses the cookie in the 2nd box to eat.
- Day 2: There are cookies in the 3rd and 5th boxes. He chooses the cookie in the 5th box to eat.
- After two days have passed, only the 3rd box from the left contains a cookie. Therefore, four out of the five boxes are empty.
Even though Takahashi might choose differently on each day than in this example, there will still be four empty boxes after two days. Therefore, the answer is 4.
Sample Input 2
3 3 @@@
Sample Output 2
3
Sample Input 3
10 4 @@@.@@.@@.
Sample Output 3
7