s = eval(input())



if s=='RRR':print((3))

if s=='SSS':print((0))



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

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



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

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



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

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

s = eval(input())

if s == 'RRR': print((3))

elif s == 'SSS': print((0))

elif s[0:2] == 'RR': print((2))

elif s[1:3] == 'RR': print((2))

else: print((1))

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

s = eval(input())
if s == "RRR":
    print((3))
elif s == "SSS":
    print((0))
elif s[0:2] == "RR":
    print((2))
elif s[1:3] == "RR":
    print((2))
else:
    print((1))

-if s == "SSS": +elif s == "SSS": -if s == "RRS": +elif s[0:2] == "RR": -if s == "SSR": +elif s[1:3] == "RR": +    print((2)) +else: -if s == "RSR": -    print((1)) -if s == "SRS": -    print((1)) -if s == "SRR": -    print((2)) -if s == "RSS": -    print((1))