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