S = input()

if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    ans = 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'):
    ans = 2
elif S[0] == 'S' and S[1] == 'S' and S[2] == 'S':
    ans = 0
else:
    ans = 1

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

if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    ans = 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'):
    ans = 2
elif S[0] == 'S' and S[1] == 'S' and S[2] == 'S':
    ans = 0
else:
    ans = 1

print(ans)
