s = input()
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'):
    print(2)
elif(s[0] == 'S' and s[1] == 'R' and s[2] == 'R'):
    print(2)
elif(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'):
    print(1)
else:
    print(0) s = input() s input() input 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'):
    print(2)
elif(s[0] == 'S' and s[1] == 'R' and s[2] == 'R'):
    print(2)
elif(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'):
    print(1)
else:
    print(0) s[0] == 'R' and s[1] == 'R' and s[2] == 'R' s[0] == 'R' and s[1] == 'R' s[0] == 'R' s[0] s 0 'R' s[1] == 'R' s[1] s 1 'R' s[2] == 'R' s[2] s 2 'R' print(3) print 3 elif(s[0] == 'R' and s[1] == 'R' and s[2] == 'S'):
    print(2) s[0] == 'R' and s[1] == 'R' and s[2] == 'S' s[0] == 'R' and s[1] == 'R' s[0] == 'R' s[0] s 0 'R' s[1] == 'R' s[1] s 1 'R' s[2] == 'S' s[2] s 2 'S' print(2) print 2 elif(s[0] == 'S' and s[1] == 'R' and s[2] == 'R'):
    print(2) s[0] == 'S' and s[1] == 'R' and s[2] == 'R' s[0] == 'S' and s[1] == 'R' s[0] == 'S' s[0] s 0 'S' s[1] == 'R' s[1] s 1 'R' s[2] == 'R' s[2] s 2 'R' print(2) print 2 elif(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'):
    print(1) s[0] == 'R' or s[1] == 'R' or s[2] == 'R' s[0] == 'R' or s[1] == 'R' s[0] == 'R' s[0] s 0 'R' s[1] == 'R' s[1] s 1 'R' s[2] == 'R' s[2] s 2 'R' print(1) print 1 print(0) print 0 s = input() input() s
s = input()
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'):
    print(2)
elif(s[0] == 'S' and s[1] == 'R' and s[2] == 'R'):
    print(2)
elif(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'):
    print(1)
else:
    print(0)
