peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
a = [int(_) for _ in input().split()]
ans = 0
h = a[0]
if n == 1:
    print(0)
else:
    for i in range(1, n):
        if a[i] < h:
            ans += h - a[i]
        else:
            h = a[i]
print(ans)
n=int(input())
l=list(map(int,input().split()))
ans=0
maxt=0
for i in l:
  if i<maxt:
    ans+=maxt-i
    maxt=max(i,maxt)
print(ans)
tot = int(input())
ls = list(map(int,input().split()))
ans = 0
mx = 0
for i in range(0,tot):
    if mx < ls[i]:
        mx = ls[i]
    if i != 0:
        if ls[i] < ls[i-1]:
            ans += mx - ls[i]
print(ans)
n=int(input())
l=list(map(int,input().split()))
tmp=l[0]
ans=0
for i in range(n-1):
    if l[i+1]<l[i]:
        ans+=(tmp-l[i+1])
    else:
        tmp=l[i+1]
print(ans)
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
  i=i+1
r=i
for b in range(r,len(l)):
    d=d+(u-l[b])
print(d)
n = int(input())
a = [int(s) for s in input().split()]
count = 0
max = a[0]
for i in range(1, len(a)):
    if a[i - 1] > a[i]:
        if a[i - 1] > max:
            max = a[i - 1]
        count += max - a[i]
    else:
        max = a[i]
print(count)
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
 
sum_step = 0
 
for n in range(1, N):
  if A[n] >= A[n-1]:
    pass
  else:
    sum_step += A[n-1] - A[n]
  
print(sum_step)
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    mi = 0
    le = len(a)
    cost = 0
    for i in range(le-1):
        if a[i] > a[i+1]:
            mi = max(a[i], mi)
            cost += mi - a[i+1]
            print(mi - a[i+1], mi)
    print(cost)
    return 0

if __name__ == "__main__":
    solve()
N = int(input())
A = list(map(int, input().split()))

c = 0
for i in range(1, N):
  b = A[i-1]
  c += A[i] - b
  
print(c)
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(1,N):
    tmp = A[i-1] - A[i]
    if A[i-1] > A[i]:
        A[i] += tmp
        ans += tmp
print(A)
print(ans)
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  if(i == 0):
    pass
  else:
    if(A[i] - A[i-1] <= 0):
      pass
    else:
      ans += A[i] - A[i-1]
print(ans)
n = int(input())
H = list(map(int, input().split()))
mh = 0
ans = 0
for i in range(n - 1):
    mh = max(mh, H[i])
    if H[i] <= H[i + 1]:
        continue
    else:
        if H[i + 1] < H[i]:
            ans = max(ans, mh - H[i + 1])

print(ans)
n = int(input())
As =list(map(int,input().split()))

sum = 0
step =0

try:
    for i in range(n):
        if As[i] > As[i + 1]:
            step = As[i] - As[i + 1]
            As[i + 1] += step
            sum += step 
except IndexError:
    pass


for i in range(len(As)):
    print(As[i],end=" ")
else:
    print("")
print(sum)
n = int(input())
As = list(map(int, input().split()))
mx = 0
prev = -1
ans = 0
for a in As:
    if prev < a:
        mx = a
    else:
        ans += mx - a
    prev = a
print(ans)
n = int(input())
l = list(map(int,input().split()))

sum=0
l.sort()
for i in range(len(l)-1):
    if l[i+1]>l[i]:
        sum+=l[i+1]-l[i]

print(sum)
n = int(input())
As =list(map(int,input().split()))

sum = 0
step =0


for i in range(n):
    try:
        if As[i] > As[i + 1]:
            step = As[i] - As[i + 1]
            As[i + 1] += step
            sum += step 
    except IndexError:
        continue


for i in range(len(As)):
    print(As[i],end=" ")
else:
    print("")
print(sum)
n = int(input())
lst = list(map(int, input().split()))
count = 0
t = 0
for i in range(n-1):
    if lst[i] < lst[i+1]:
        t += lst[i+1] - lst[i]
        count += t
        lst[i+1] = t
print(count)
N = int(input())
A = list(map(int, input().split()))
ans = 0
tgt = A[0]
for i in range(1, N):
    if A[i-1] < A[i]:
        tgt = A[i]
    elif A[i-1] > A[i]:
        ans += tgt - A[i]

print(ans)
n = int(input())
a = list(map(int,input().split()))
ans = 0
m = a[0]
for i in range(1,n):
  if a[i] > m:
    ans += a[i]-m
    m = a[i]
print(ans)
N = int(input())
A = list(map(int, input().split()))

mini = A[0]
ans = 0

for i in range(len(A) - 1):
    if A[i] < A[i+1]:
        ans += A[i+1] - A[i]
        A[i] = A[i+1]
print(ans)
def resolve():
    N = input()
    string = input()
    max_height = 0
    s = 0
    for c in string:
        if c == " ":
            continue
        h = int(c)
        if h < max_height:
            s += max_height - h
        elif h > max_height:
            max_height = h

    print(s)
resolve()
n=int(input())

a=list(map(int,input().split()))
  
b=[]
if n>1:
  for j in range (n-1):
    c=a[j]-a[j+1]
    b.append(c)
    a[j+1]=a[j+1]+c

  if max(b)>-1:
    print(max(b))
  else:
    print(0)
    
else:
  print(0)
_ = input()
li = list(map(int,input().split()))
ans=0
 
while li!=[] and li!=sorted(li):
    maxValue = max(li)
    maxLocation = li.index(maxValue)
    
    li_removed = li[maxLocation:]
    li = li[:maxLocation]
    
    li_removed.sort()
    
    print(li_removed)
    
    for i in li_removed[:li_removed.index(maxValue)-1]:
        
        ans = ans + (maxValue - i)
        
print(ans)
n = int(input())
a_list = list(map(int, input().split()))

h_list = [0]*(n+10)

for i in range(1,n):
    if a_list[i] < a_list[i-1]:
        h_list[i] = a_list[i-1] + h_list[i-1] - a_list[i] 
    elif a_list[i] >= a_list[i-1]:
        h_list[i] = 0
        
print(sum(h_list))
N = int(input())
A = list(map(int, input().strip().split()))
ans = 0
for i in range(1, N):
  ans += max(0, A[i] - A[i - 1])
  A[i] = max(A[i], A[i - 1])
print(ans)
n = int(input())
a = list(map(int,input().split()))
cnt = 0

for i in range(n-1):
  if a[i+1] > a[i]:
    cnt += a[i+1]-a[i]

print(cnt)
n = int(input())
a = list(map(int, input().split()))

res = a[0]
ans = 0
for i in range(n-1):
  if a[i]>=a[i+1]:
    ans += res-a[i+1]
  else:
    res = a[i+1]
    
print(ans)
def stepUp(val_list):
  counter = 0

  for i in range(len(val_list) - 1):
      current = val_list[i]
      up = val_list[i + 1]

      if (current > up):
          counter += current - up

  if (val_list[len(val_list) - 2] > val_list[len(val_list) -1]):
      counter += val_list[len(val_list) - 2] - val_list[len(val_list) -1]

  return counter

def userInput():
    a_count = int(input())
    a = list(map(int, input().rstrip().split()))
    
    return stepUp(a)
  
print(userInput())
n = int(input())
a = list(map(int, input().split()))

count = 0

for i, j in enumerate(a):
    try:
        if j < a[i - 1]:
            b = a[i - 1] - j
            count += b
            j += b
        else:
            pass
    except IndexError:
        pass

print(count)
n=int(input())
l=list(map(int,input().split()))
s=0
p=0
for i in range(n):
    h_need=p+l[i-1]
    if h_need>l[i]:
        p=h_need-l[i]
        s+=p
    else:h_need=l[i-1]
print(s)
n = int(input())
a = list(map(int, input().split()))

amax = max(a)
x = a.index(amax)
if x > 0:
   bmax = max(a[:x])
   y = a.index(bmax)
else:
   bmax = 0
   y = 0

ans = 0
for i in range(n):
   if i >= y and i < x:
      ans += max(0, bmax-a[i])
   elif i >= x:
      ans += max(0, amax-a[i])
print(ans)
n=int(input())
a=list(map(int,input().split()))
s=max(a)
k=0
for i in range(0,(a.index(s))):
    
    if a[i]>a[i+1]:
        k+= (a[i] - a[i+1])
    else:
        continue
for i in range(a.index(s),n):
    if a[i]<s:
        k+= s-a[i]
    else:
        continue
print(k)
s = input()
if s == "SSS":
  print(0)
elif s == "RRR":
  print(3)
elif s == "SRR" or s == "RRS":
  print(2)
else:
  print(1)
s = input()
rain_max = 0
local_max = 0
for i in range(len(s)):
    if s[i] == 'R':
        local_max += 1
    else:
        if local_max > rain_max:
            rain_max = local_max
        local_max = 0
if local_max > rain_max:
    rain_max = local_max
print(rain_max)
n = input()

rcount = 0
m = 0
for i in n:
  if i == "R":
    rcount += 1
  else:
    rcount = 0
  
  if m <= rcount:
    m = rcount
print(m)
s=input()
s=list(s)
s_c = s.count('R')
if s[1]=='S' and s_c==2:
  s_c=1
print(s_c)
S = input()
if S == "RRR":
    print(3)
elif "RR" in S:
    print(2)
elif "R" in S:
    print(1)
else:
    print(0)
s = input()
if s == "RRR":
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
S = input()

rst = 0
for i in range(0,3):
  cnt = 0
  if S[i] == "R":
    cnt += 1
    for j in range(i+1,3):
      if S[j] == "R":
        cnt+= 1
      else:
        break
  rst = max(rst,cnt)
print(rst)
s = input()

if s=="RRR":
    print(3)
elif s=="RRS" or s=="SRR":
    print(2)
elif s=="SSS":
    print(0)
else:
    print(1)
s = input()
count = 0
if(s[1]=='R'):
  for i in s:
    if(i=='R'):
      count+=1
else:
  for i in s:
    if(i=='R'):
      count = 1
print(count)
S = input()
if 'RRR' in S:
    print(3)
elif 'RR' in S:
    print(2)
elif 'R' in S:
    print(1)
else:
    print(0)
n = input()
if n == "RRR":
    print("3")
elif n[:2] == "RR" or n[1:] == "RR":
    print("2")
elif n=="SSS":
    print("0")
else:
    print("1")
S = input()
if(S=="RRR"):
  print(3)
elif(S=="RRS" or S=="SRR"):
  print(2)
elif(S[0]=="R" or S[1]=="R" or S[2]=="R"):
  print(1)
else:
  print(0)
S = input()

if S == "SSS":
    print(0)
if S == "RSS":
    print(1)
if S == "RRS":
    print(2)
if S == "RRR":
    print(3)
if S == "SRS":
    print(1)
if S == "SSR":
    print(1)
if S == "SRR":
    print(2)
if S == "RSR":
    print(1)
S = input()

if S[0] == "R":
    if S[1] =="R":
        if S[2]=="R":
            print(3)
        else:
            print(2)
    else:
        print(1)
else:
    if S[1] =="R":
        if S[2]=="R":
            print(2)
        else:
            print(1)
    else:
        if S[2]=="R":
            print(1)
        else:
            print(0)
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()

    if S.count("RRR"):
        print(3)
    elif S.count("RR"):
        print(2)
    elif S.count("R"):
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()
w=input()
if w=="RRR":
    print(3)
elif w=="SRR":
    print(2)
elif w=="RRS":
    print(2)
elif w=="RSR":
    print(1)
elif w=="RSS":
    print(1)
elif w=="SRS":
    print(1)
elif w=="SSR":
    print(1)
else :
    print(0)
S = input()

if S == 'RRR':
    print(3)
else:
    if S == 'RRS' or S == 'SRR':
        print(2)
    else:
        if S =='SSS':
            print(0)
        else:
            print(1)
num = list(map(str,input()))
if num[0]== 'R' and num[1] =='S':
    print('1')
else:
    print(num.count('R'))
# -*- coding: utf-8 -*-
s = input()

if s == 'RRR':
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)
s = input()
cnt = 0

if 'RRR' in s:
    print(3)
    exit()
if 'RR' in s:
    print(2)
    exit()
if 'R' in s:
    print(1)
    exit()

print(0)
def main():
    s = input().split('S')
    x = max(map(len,s))
    print(x)

main()
S = input()

result = 0
if S == "RRR":
    result = 3
elif S == "RRS" or S == "SRR":
    result = 2
elif "R" in S:
    result = 1

print(result)
s=input()

ans=0
num=0
for i in range(len(s)):

    if s[i] == 'R':

        num+=1

    else:
        num=0

    if num>ans:
        ans=num

print(ans)
s = input().strip()

if (s[0] == "R") and (s[1] =="R") and (s[2] =="R"):
  print(3)
elif (s[0] == "R" and s[1] == "R" and s[2] == "S")or(s[0] == "S" and s[1] == "R" and s[2] == "R"):
  print(2)
elif s[0] == "S" and s[1] == "S" and s[2] == "S":
  print(0)
else:
  print(1)
S = list(input())
RD = S.count('R')
if RD != 2:
    print(RD)
else:
    if S[1] == 'R':
        print(RD)
    else:
        print(1)
S = list(input())

cnt = 0
for i, s in enumerate(S):
  if s == 'R' and cnt == 0:
    cnt +=  1
  elif s == 'R' and cnt >= 1 and S[i-1] == 'R':
    cnt += 1

print(cnt)
s=str(input())
R=s.count('R')
if s=='RSR':
    print(1)
else:
    print(R)
str = input()
ans = 0
list_ans=[]
flag = 0
for i in range(len(str)):
    if str[i] == 'R':
        if flag == 0:
            ans = 1
        else:
            ans += 1
        flag = 1
    else:
        flag = 0
        list_ans.append(ans)
list_ans.append(ans)
print(max(list_ans))
S = input()
cur = 0
ans = 0
for i in range(len(S)):
    if S[i] == "R":
        cur += 1
    else:
        ans = max(ans, cur)
        cur = 0
ans = max(ans, cur)
print(ans)
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
if S[0] == S[1] == S[2] == "R":
    print(3)
elif S[0:2] == "RR" or S[1:3] == "RR":
    print(2)
elif "R" in S:
    print(1)
else:
    print(0)
S = input()

compareStr = 'R' * len(S)

while len(compareStr) > 0:
    if compareStr in S:
        break
    compareStr = compareStr[:-1]

print(len(compareStr))
s = input()


if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)
s = input()
ans = 0
for r in s:
    if r == 'R':
        ans += 1
if ans == 2 and s == 'RSR':
    print(1)
else:
    print(ans)
s=input()
if ("RRR" in s):
  print(3)
elif ("RR" in s):
  print(2)
elif ("R" in s):
  print(1)
else:
  print(0)
s=input()

cnt=0

for i in range(3):
    if(s[i]=='R'):
        cnt+=1

if(cnt!=2):
    print(cnt)
elif(s=="RSR"):
    print(1)
else:
    print(2)
s = list(input())

if s.count('R') == 3:
    print(3)
elif s.count('R') == 1:
    print(1)
elif s.count('R') == 0:
    print(0)
else:
    if s[1] == 'R':
        print(2)
    else:
        print(1)
s = str(input())

n = len(s)
c = 0

for i in range(n):
    if s[i] == "R":
        j = i
        a = 0
        while s[j] == "R" and j < n-1:
            a += 1
            j += 1
        if j == n-1 and s[j] == "R":
            a += 1
        c = max(a,c)

print(c)
S=list(input().split("S"))
print(max(len(s) for s in S))
def resolve():
	S = input()
	mark = ""
	count = 0
	max_count = 0
	for s in list(S):
		if s == "R":
			count += 1
		else:
			max_count = max(max_count, count)
			count = 0
			mark = s
	max_count = max(max_count, count)
	print(max_count)
resolve()
s = input()

if s == "RRR":
    print(3)
elif s == "RRS" or s == "SRR":
    print(2)
elif s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR":
    print(1)
else:
    print(0)
s = input()
ans = 0
if 'RRR' in s:
    ans = 3
elif 'RR' in s:
    ans = 2
elif 'R' in s:
    ans = 1

print(ans)
D = input()
ans = 0
ans_list = []
if D.count("R") >= 1:
  for i in range(3):
    if D[i] == 'R':
      ans += 1
      ans_list.append(ans)
    elif D[i] == 'S':
      ss = 0
      ans_list.append(ss)
      if i > 0:
        ans = 0
  print(max(ans_list))
elif D.count("R") < 1:
  print(0)
S=input()
if S=="RRR":
    print(3)
elif S=="RRS" or S=="SRR":
    print(2)
elif S.count("R")>0:
    print(1)
else:
    print(0)
import re

S = input()

rrr = S.count("RRR")
rr = S.count("RR")
r = S.count("R")

if rrr == 1:
    print(3)
elif rr == 1:
    print(2)
elif r == 1 or r == 2:
    print(1)
else:
    print(0)
#175 A
S = input()
if S == 'RRR':
    print(3)
elif S == 'SRR' or S == 'RRS':
    print(2)
elif S == 'SSS':
    print(0)
else:
    print(1)
s = input()
if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'R' in s:
  print(1)
else:
  print(0)
S=input()
if S=="RRR" :
  print(3)
elif S=="RRS" :
  print(2)
elif S=="SRR" :
  print(2)
elif S=="RSS" :
  print(1)
elif S=="SRS" :
  print(1)
elif S=="SSR" :
  print(1)
elif S=="RSR" :
  print(1)
else :
  print(0)
s = input()
if "RRR" in s:
    r = 3
elif "RR" in s:
    r = 2
elif "R" in s:
    r= 1
else:
    r = 0
print(r)
S = input()

def it(s):
    c = 0
    for v in s:
        if v == 'R':
            c += 1
        else:
            c = 0
        yield c

print(max(it(S)))
s = input()

w_l = s.split('S')
print(max([m for m in map(len, w_l)]))
S = input()

ans = 0
tmp = 0
for i in S:
    if i == 'R':
        tmp += 1
    else:
        ans = max(tmp,ans)
        tmp = 0

ans = max(tmp,ans)

print(ans)
def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

s = input()
ans  = 0
tmp = 0
for i in s:
    if i == 'R':
        tmp += 1
        ans  = max(ans, tmp)
    else:
        tmp = 0
    
print(ans)
S = input()
sum = 0
for i in range(3):
    if S[i]=="R":
        sum += 1
if sum == 2 and S[1] == "S":
        sum = 1
print(sum)
weather = input().rstrip()
#print(weather)

if weather.count('RRR') == 1:
    print(3)
elif weather.count('RR') == 1:
    print(2)
elif weather.count('R') >= 1:
    print(1)
else:
    print(0)
S = input()

count = S.count("R")
if count == 2 and S[0] == "R" and S[2] == "R":
    count = 1
print(count)
# from pprint import pprint
# import math
# import collections

s = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
# a = []
# for i in range(n):
#     a.append(int(input()))

if s == 'RRR':
    ans = 3
elif s in ('RRS', 'SRR'):
    ans = 2
elif s == 'SSS':
    ans = 0
else:
    ans = 1

print(ans)
s=input()
if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)
S = input()

if S == 'RSS':
    print(1)
    exit()

tmp = 0
for i in range(len(S)):
    if S[i] == 'R':
        tmp += 1
    else:
        if i == 2:
            break
        else:
            tmp = 0
print(tmp)
tenki = str(input())
count = 0
tenki_list = []
for n in tenki:
    if n == 'R':
        count +=1
    else:
        count = 0
    tenki_list.append(count)
print(max(tenki_list))
S = input()
count = 0
mcount = 0
for i in range(len(S)):
	if(S[i] == 'S'):
		count = 0
	elif(S[i] == 'R'):
		count += 1
		if(count>mcount):
			mcount = count
print(mcount)
s=input()
a=s.count("R")
if a==0:
    print(0)
elif a==1:
    print(1)
elif a==2:
    if s[1]=="S":
        print(1)
    else:
        print(2)
else:
    print(3)
S=list(input())
ans=0

for i in range(len(S)):
    if ans==0 and S[i]=="R":
        ans=1
for i in range(len(S)-1):
    if S[i]=="R" and S[i+1]=="R":
        ans+=1

print(ans)
# -*- coding: utf-8 -*-

def main():
    s = str(input())

    if s == "RRR":
        print(3)
    elif s == "RRS" or s == "SRR":
        print(2)
    elif s == "SSS":
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline
from collections import *

s = input()[:-1]
l = []
cnt = 1
    
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        l.append((s[i], cnt))
        cnt = 1
    else:
        cnt += 1
    
l.append((s[-1], cnt))
ans = 0

for si, c in l:
    if si=='R':
        ans = max(ans, c)

print(ans)
S = input()
for i in range(4)[::-1]:
    if 'R' * i in S:
        print(i)
        exit()
s=input()

if "RRR" in s:
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
W = input()
if W[0] == 'R' and  W[1] == 'R' and  W[2] == 'R':
    print(3)
elif (W[0] == 'R' and  W[1] == 'R') or (W[1] == 'R' and  W[2] == 'R'):
    print(2)
elif W[0] == 'S' and  W[1] == 'S' and  W[2] == 'S':
    print(0)
else:
    print(1)
S = input()
count = 0
if S == 'RSR':
  print(1)
else:
  for i in S:
    if i == 'R':
      count+=1
  print(count)
string = input()
result = string.count("R")
if(result == 2 and string[1] == "S"):
  print("1")
else:
  print(result)
S = input()

count = S.count('R')

if count == 0 or count == 1 or count == 3:
    print(count)
else:
    if S == 'RSR':
        print(1)
    else:
        print(2)
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    if "RRR" in S:
        ans = 3
    elif "RR" in S:
        ans = 2
    elif "R" in S:
        ans = 1
    else:
        ans = 0

    print(ans)


if __name__ == "__main__":
    main()
str = input()
cnt = 0
 
for i in range(3):
  if str == 'RRR':
    cnt = 3
  elif str == 'RRS':
    cnt = 2
  elif str == 'SRR':
    cnt = 2
  elif str == 'SSS':
    cnt = 0
  else:
    cnt = 1
    
print(cnt)
# A
s = input()
count = 0
ans = 0
for i in range(len(s)):
    if s[i] == "R":
        count += 1
    else:
        if ans < count:
            ans = count
        count = 0
if ans < count:
    ans = count
print(ans)
s = input().split('S')

ans = 0

for i in s:
  if len(i) > ans:
    ans = len(i)
    
print(ans)
x = input()
a = [int(x[i]=='R') for i in range(3)]
s = sum(a)
if(s==2 and a[1]==0):
  s = 1
print(s)
S = input()
cnt = 0
for i,ch in enumerate(S):
  if cnt == 0:
    if ch == "R":
      cnt = 1
  elif ch == "R" and S[i-1] == "R":
    cnt += 1
print(cnt)
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

s = input().rstrip()
if "RRR" in s:
    print(3)
elif "RR" in s:
    print(2)
elif "R" in s:
    print(1)
else:
    print(0)
s = input()

if 'RRR' in s:
    print(3)
elif 'RR' in s:
    print(2)
elif 'R' in s:
    print(1)
else:
    print(0)
S = input()
count = 0
if 'R' in S:
    count = 1
if 'RR' in S:
    count = 2
if 'RRR' in S:
    count = 3
print(count)
N=input()
if N==('SSS'):
    print(0)

if N==('SSR'):
    print(1)

if N==('SRS'):
    print(1)

if N==('RSR'):
    print(1)

if N==('RSS'):
    print(1)

if N==('SRR'):
    print(2)

if N==('RRS'):
    print(2)

if N==('RRR'):
    print(3)
a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:
  print(0)
S = input()
count = 0
if S[0] == "R" and S[1] == "R":
    if S[2] == "R":
        count = 3
    else:
        count = 2
if S[0] == "R" and S[1] == "S":
    count = 1
if S[0] == "S" and S[1] == "R":
    if S[2] == "R":
        count = 2
    else:
        count = 1
if S[0] == "S" and S[1] == "S":
    if S[2] == "R":
        count = 1
    else:
        count = 0
print(count)
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    S = input()

    if S == "RRR":
        print(3)
    elif S[1:3] == "RR" or S[0:2] == "RR":
        print(2)
    else:
        ans = 0
        for s in S:
            if s == "R":
                ans = 1
        print(ans)






if __name__ == "__main__":
    main()
def solve(s):

  res=0

  for i in range(len(s)):
    if s[i]=="R":
      res+=1

    elif s[i]=="S" and res>0:
      return res
  return res
  
s=input()
print(solve(s))
S = input()
# RC = S.count('R')
# if S[1] == 'S' and RC == 2:
    # print(1)
# else:
    # print(RC)

rs = S.split('S')
ans = 0
for r in rs:
    ans = max(ans, len(r))
print(ans)
line = input()
rain_day = 0
k = 0
for wether in line:
  #当日雨
  if wether == "R":
    rain_day += 1
  #当日晴れ、前日は雨
  elif rain_day != 0:
    k = rain_day
    rain_day = 0
  #当日晴れ、前日も晴れ
  else:
    pass
if k > rain_day:
  print(k)
else:
  print(rain_day)
A = input()
count = 0
for a in range(3):
    if A[a] == 'R':
      count+=1
      
if count == 2 and A[1] == 'S':
      count = 1
print(count)
S=input()
if S== 'RRR':
    print(3)
elif S=='RRS' or S=='SRR':
    print(2)
elif S=='SSS':
    print(0)
else:
    print(1)
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    S = input()
    if 'RRR' in S:
        return 3
    if 'RR' in S:
        return 2
    if 'R' in S:
        return 1
    return 0


if __name__ == '__main__':
    print(solve())
s=input()
if s.count('R')==3:
  print(3)
elif s[0]==s[1]=='R' or s[1]==s[2]=='R':
  print(2)
elif s.count('R')!=0:
  print(1)
else:
  print(0)
S=input()
print(max(i for i in range(4)if S.count("R"*i)))
S = input()
a = 0
if S == 'RSR':
    print(1)
else:
    for i in S:
        if i == 'R':
            a += 1
    print(a)
str = input()
if str == "RRR":
    print("3")
elif str == "RRS" or str == "SRR":
    print("2")
elif str == "SSS":
    print("0")
else:
    print("1")
S = input()

if 'RSR' in S:
	print(1)
else:
	print(S.count("R"))
s = input()
maxCount = 0
count = 0

for i in s:
  if(i == 'R'):
    count += 1
  else:
    maxCount = max(count, maxCount)
    count = 0
    
print(max(count, maxCount))