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# (.NET Core 3.1.201) (judge verdict: Runtime Error)

using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = myRead.readLongArray();
            var p = myRead.readLongArray().Select(x => x - 1).ToArray();
            var c = myRead.readLongArray();
            long ans = 0;
            long sum = 0;
            foreach (var x in c)
            {
                sum += x;
            }
            if (sum < 0)
            {
                sum = 0;
                for (int i = 0; i < s[0]; i++)
                {
                    int j = i;
                    ans = -1000000000;
                    for (int k = 0; k < s[1]; k++)
                    {
                        sum += c[j];
                        j = (int)p[j];
                        if (sum > ans)
                            ans = sum;
                        if (sum < 0)
                            break;
                    }
                }
            }
            else if (s[0] > s[1])
            {
                long result = 0;
                for (int i = 0; i < s[0]; i++)
                {
                    long a = 0;
                    int j = i;
                    for (int k = 0; k < s[1]; k++)
                    {
                        a += c[j];
                        j = (int)p[j];
                    }
                    if (a > ans)
                        ans = a;
                }
            }
            else
            {
                ans += sum * (s[1] / s[0]);
                long num = s[1] % s[0];
                long amari = 0;
                for (int i = 0; i < s[0]; i++)
                {
                    long a = 0;
                    int j = i;
                    for (int k = 0; k < num; k++)
                    {
                        a += c[j];
                        j = (int)p[j];
                    }
                    if (a > amari)
                        amari = a;
                }
                ans += amari;
            }
            WriteLine(ans);
        }
    }
    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string reatStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }


    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); }
    }


}