weatherS = input()
p = weatherS[0] == 'R'
q = weatherS[1] == 'R'
r = weatherS[2] == 'R'

if p and q and r:
    serial = 3
elif (p and q) or (q and r):
    serial = 2
elif p or q or r:
    serial = 1
else:
    serial = 0

print(serial) weatherS = input() weatherS input() input p = weatherS[0] == 'R' p weatherS[0] == 'R' weatherS[0] weatherS 0 'R' q = weatherS[1] == 'R' q weatherS[1] == 'R' weatherS[1] weatherS 1 'R' r = weatherS[2] == 'R' r weatherS[2] == 'R' weatherS[2] weatherS 2 'R' if p and q and r:
    serial = 3
elif (p and q) or (q and r):
    serial = 2
elif p or q or r:
    serial = 1
else:
    serial = 0 p and q and r p and q p q r serial = 3 serial 3 elif (p and q) or (q and r):
    serial = 2 (p and q) or (q and r) p and q p q q and r q r serial = 2 serial 2 elif p or q or r:
    serial = 1 p or q or r p or q p q r serial = 1 serial 1 serial = 0 serial 0 print(serial) print serial weatherS = input() input() weatherS r = weatherS[2] == 'R' weatherS[2] == 'R' r serial = 0 0 serial q = weatherS[1] == 'R' weatherS[1] == 'R' q p = weatherS[0] == 'R' weatherS[0] == 'R' p serial = 1 1 serial serial = 3 3 serial serial = 2 2 serial
weatherS = input()
p = weatherS[0] == 'R'
q = weatherS[1] == 'R'
r = weatherS[2] == 'R'

if p and q and r:
    serial = 3
elif (p and q) or (q and r):
    serial = 2
elif p or q or r:
    serial = 1
else:
    serial = 0

print(serial)