B - K-th Departure Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 233 点

問題文

高橋君の町の港では、 N 日間の出航予定が長さ N の文字列 S で表されています。 S の i 文字目が S なら i 日目に船が出航し、 . なら出航しません。

高橋君は K 回目の出航に乗りたいです。 K 回目の出航は何日目かを求めてください。 N 日間の出航の回数が K 回に満たない場合は -1 を出力してください。

制約

  • 1 \leq N \leq 100
  • 1 \leq K \leq 100
  • S は S と . のみからなる長さ N の文字列
  • N と K は整数

入力

入力は以下の形式で標準入力から与えられる。

N K
S
  • 1 行目には、日数 N と乗りたい出航の順番 K がスペース区切りで与えられる。
  • 2 行目には、出航予定を表す文字列 S が与えられる。

出力

K 回目の出航が何日目かを 1 行で出力せよ。出航の回数が足りない場合は -1 を出力せよ。


入力例 1

7 2
.S..S.S

出力例 1

5

入力例 2

4 1
...S

出力例 2

4

入力例 3

5 3
SSSSS

出力例 3

3

入力例 4

42 25
.SSS.SSSSSS.S....SSS..SSS..SS.SS.SSS.SS..S

出力例 4

39

入力例 5

55 10
SSSS........SSS..SS..SS.SSSS..S.S.S.S..SS.S.SS..SSS.SSS

出力例 5

22

Score : 233 pts

Problem Statement

At the port in Takahashi's town, the departure schedule for N days is represented by a string S of length N. If the i-th character of S is S, a ship departs on day i; if it is ., no ship departs.

Takahashi wants to board the K-th departure. Find on which day the K-th departure occurs. If the number of departures during the N days is fewer than K, print -1.

Constraints

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

Input

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

N K
S
  • The first line contains the number of days N and the ordinal K of the departure Takahashi wants to board, separated by a space.
  • The second line contains the string S representing the departure schedule.

Output

Print on a single line the day on which the K-th departure occurs. If the number of departures is insufficient, print -1.


Sample Input 1

7 2
.S..S.S

Sample Output 1

5

Sample Input 2

4 1
...S

Sample Output 2

4

Sample Input 3

5 3
SSSSS

Sample Output 3

3

Sample Input 4

42 25
.SSS.SSSSSS.S....SSS..SSS..SS.SS.SSS.SS..S

Sample Output 4

39

Sample Input 5

55 10
SSSS........SSS..SS..SS.SSSS..S.S.S.S..SS.S.SS..SSS.SSS

Sample Output 5

22