A - 連続勝利の記録 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 233

問題文

高橋君は、過去 N 試合の勝敗の記録を調べています。各試合の結果は「勝ち」を表す W または「負け」を表す L のいずれかで記録されています。

高橋君は、この記録の中で最も長く連続して勝利した試合数を知りたいと思っています。

試合数 N と、勝敗を表す長さ N の文字列 S が与えられたとき、S に含まれる W の最長連続部分の長さを求めてください。W が一つも含まれない場合、答えは 0 です。

制約

  • 1 \leq N \leq 10^6
  • SWL のみからなる長さ N の文字列である。

入力

入力は以下の形式で与えられます。

N
S
  • 1 行目には、試合数を表す整数 N が与えられる。
  • 2 行目には、WL のみからなる長さ N の文字列 S が与えられる。

出力

S に含まれる W の最長連続部分の長さを整数で一行に出力してください。


入力例 1

8
WLWWWLLW

出力例 1

3

入力例 2

5
LLLLL

出力例 2

0

入力例 3

20
WWLLWWWWWLWLWWWLLLWW

出力例 3

5

入力例 4

60
LWWWWLWWWLLWWWWWWLWLWWWWLWWLLLLWWWWWWWLWLWWWWWWWWLLLWWLWWWWW

出力例 4

8

入力例 5

1
W

出力例 5

1

Score : 233 pts

Problem Statement

Takahashi is examining the record of wins and losses from his past N matches. The result of each match is recorded as either W representing a "win" or L representing a "loss".

Takahashi wants to know the longest streak of consecutive wins in this record.

Given the number of matches N and a string S of length N representing the wins and losses, find the length of the longest consecutive sequence of W in S. If S contains no W at all, the answer is 0.

Constraints

  • 1 \leq N \leq 10^6
  • S is a string of length N consisting only of W and L.

Input

The input is given in the following format.

N
S
  • The first line contains an integer N representing the number of matches.
  • The second line contains a string S of length N consisting only of W and L.

Output

Print the length of the longest consecutive sequence of W in S as an integer on a single line.


Sample Input 1

8
WLWWWLLW

Sample Output 1

3

Sample Input 2

5
LLLLL

Sample Output 2

0

Sample Input 3

20
WWLLWWWWWLWLWWWLLLWW

Sample Output 3

5

Sample Input 4

60
LWWWWLWWWLLWWWWWWLWLWWWWLWWLLLLWWWWWWWLWLWWWWWWWWLLLWWLWWWWW

Sample Output 4

8

Sample Input 5

1
W

Sample Output 5

1