/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
高橋君は、連続する N 日間の天気を、各日について「晴れ」か「雨」かで記録しました。
高橋君の記録は長さ N の文字列 S として以下の形式で与えられます。
- S の i ( 1 \le i \le N ) 文字目は、記録開始から i 日目の天気を表します。
- S の i 文字目が
Sであるとき、その日の記録は「晴れ」でした。 - S の i 文字目が
Rであるとき、その日の記録は「雨」でした。
- S の i 文字目が
高橋君が「雨」を連続して記録した日数の最大値を求めてください。
ただし、高橋君が「雨」を一度も記録しなかった場合、答えは 0 であるとします。
制約
- N は 1 \le N \le 100 を満たす整数
- S は
SとRからなる長さ N の文字列
入力
入力は以下の形式で標準入力から与えられる。
N S
出力
答えを出力せよ。
入力例 1
7 RRSRRRS
出力例 1
3
高橋君は、初日から順に 雨、雨、晴れ、雨、雨、雨、晴れ を記録しました。
4,5,6 日目に「雨」が連続して記録され、これより長い「雨」の連続した記録はないため、「雨」を連続して記録した日数の最大値は 3 です。
入力例 2
10 SSSSSSSSSS
出力例 2
0
高橋君は「雨」を一度も記録していません。この場合、答えは 0 です。
入力例 3
20 RRRSRRRRSSRRRRSRSRRR
出力例 3
4
Score : 200 points
Problem Statement
Takahashi recorded the weather for N consecutive days, recording each day as "sunny" or "rainy".
His record is given as a string S of length N in the following format.
- The i-th character ( 1 \le i \le N ) of S represents the weather on the i-th day from the start of the record.
- If the i-th character of S is
S, the record for that day was "sunny". - If the i-th character of S is
R, the record for that day was "rainy".
- If the i-th character of S is
Find the maximum number of consecutive days for which Takahashi recorded "rainy".
If Takahashi never recorded "rainy", the answer is 0.
Constraints
- N is an integer satisfying 1 \le N \le 100.
- S is a string of length N consisting of
SandR.
Input
The input is given from Standard Input in the following format:
N S
Output
Output the answer.
Sample Input 1
7 RRSRRRS
Sample Output 1
3
Starting from the first day, Takahashi recorded rainy, rainy, sunny, rainy, rainy, rainy, sunny.
"Rainy" was recorded consecutively on days 4,5,6, and there is no longer consecutive run of "rainy", so the maximum number of consecutive days with "rainy" recorded is 3.
Sample Input 2
10 SSSSSSSSSS
Sample Output 2
0
Takahashi never recorded "rainy". In this case, the answer is 0.
Sample Input 3
20 RRRSRRRRSSRRRRSRSRRR
Sample Output 3
4