Problem:
Score : 100 points

Problem Statement

We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.

Find the maximum number of consecutive rainy days in this period.

Constraints

|S| = 3

Each character of S is S or R.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of consecutive rainy days in the period.

Sample Input 1

RRS

Sample Output 1

2

We had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.

Sample Input 2

SSS

Sample Output 2

0

It was sunny throughout the period. We had no rainy days, so we should print 0.

Sample Input 3

RSR

Sample Output 3

1

We had rain on the 1-st and 3-rd days - two "streaks" of one rainy day, so we should print 1.

Solution in C (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define BUFSIZE 100000	


int n;
int h[BUFSIZE] = {0};
int dp[BUFSIZE] = {0}; 

int min(int a,int b){
  if(a > b) return b;
  else return a;
}

int k;

int main(void){
   scanf("%d %d",&n,&k);
   for(int i = 0;i < n;i++) scanf("%d",&h[i]);
  
   dp[0] = 0;   

  for(int i = 1;i < n;i++){
     dp[i] = dp[i-1] + abs(h[i-1] - h[i]);
  }

 
  for(int i = 0;i < n;i++){
     for(int j = i;j <=  i + k;j++){
	if(j >  n) break;       
         dp[j] = min(dp[j] , dp[i] + abs(h[i] - h[j]));
     }
  }

  
   printf("%d\n",dp[n-1]);

}