S = str(input())

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

if S[0]=='S' and S[1]=='S' and S[2]=='S':
  sum = 0
elif (S[0]=='R' and S[1]=='R' and S[2]=='S') or (S[0]=='S' and S[1]=='R' and S[2]=='R'):
  sum = 2
elif S[0]=='R' and S[1]=='R' and S[2]=='R':
  sum = 3
else:
  sum = 1
  
print(sum)