B - The Last Radish Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 233 点

問題文

高橋君の畑は横一列に並んだ N 個のマスからなり、左から i 番目のマスの様子は文字列 S の i 文字目で表されます。 D はそのマスに大根が植えられていることを、 . は何も植えられていないことを表します。

高橋君は最も右にある大根を収穫します。最も右にある大根は左から何番目のマスにあるかを求めてください。大根が 1 つもない場合は -1 を出力してください。

制約

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

入力

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

N
S
  • 1 行目には、マスの数 N が与えられる。
  • 2 行目には、畑の様子を表す文字列 S が与えられる。

出力

最も右にある大根が左から何番目のマスにあるかを 1 行で出力せよ。大根がない場合は -1 を出力せよ。


入力例 1

6
..D...

出力例 1

3

入力例 2

4
....

出力例 2

-1

入力例 3

3
D..

出力例 3

1

入力例 4

1
.

出力例 4

-1

入力例 5

1
D

出力例 5

1

Score : 233 pts

Problem Statement

Takahashi's field consists of N cells arranged in a row, and the state of the i-th cell from the left is represented by the i-th character of the string S. D means that a radish is planted in that cell, and . means that nothing is planted there.

Takahashi harvests the rightmost radish. Find the position (counted from the left) of the cell containing the rightmost radish. If there is no radish at all, print -1.

Constraints

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

Input

The input is given from standard input in the following format.

N
S
  • The first line contains the number of cells N.
  • The second line contains the string S representing the state of the field.

Output

Print, on a single line, the position from the left of the cell containing the rightmost radish. If there is no radish, print -1.


Sample Input 1

6
..D...

Sample Output 1

3

Sample Input 2

4
....

Sample Output 2

-1

Sample Input 3

3
D..

Sample Output 3

1

Sample Input 4

1
.

Sample Output 4

-1

Sample Input 5

1
D

Sample Output 5

1