r = list(input())
if r == ["R","S","R"] or r==["R","S","S"] or r==["S","S","R"] or r==["S","R","S"]:
  print(int(1))
elif r ==["R","R","S"] or r==["S","R","R"]:
  print(int(2))
elif r==["S","S","S"]:
  print(int(0))
else:
  print(int(3)) r = list(input()) r list(input()) list input() input if r == ["R","S","R"] or r==["R","S","S"] or r==["S","S","R"] or r==["S","R","S"]:
  print(int(1))
elif r ==["R","R","S"] or r==["S","R","R"]:
  print(int(2))
elif r==["S","S","S"]:
  print(int(0))
else:
  print(int(3)) r == ["R","S","R"] or r==["R","S","S"] or r==["S","S","R"] or r==["S","R","S"] r == ["R","S","R"] or r==["R","S","S"] or r==["S","S","R"] r == ["R","S","R"] or r==["R","S","S"] r == ["R","S","R"] r ["R","S","R"] "R" "S" "R" r==["R","S","S"] r ["R","S","S"] "R" "S" "S" r==["S","S","R"] r ["S","S","R"] "S" "S" "R" r==["S","R","S"] r ["S","R","S"] "S" "R" "S" print(int(1)) print int(1) int 1 elif r ==["R","R","S"] or r==["S","R","R"]:
  print(int(2)) r ==["R","R","S"] or r==["S","R","R"] r ==["R","R","S"] r ["R","R","S"] "R" "R" "S" r==["S","R","R"] r ["S","R","R"] "S" "R" "R" print(int(2)) print int(2) int 2 elif r==["S","S","S"]:
  print(int(0)) r==["S","S","S"] r ["S","S","S"] "S" "S" "S" print(int(0)) print int(0) int 0 print(int(3)) print int(3) int 3 r = list(input()) list(input()) r
r = list(input())
if r == ["R","S","R"] or r==["R","S","S"] or r==["S","S","R"] or r==["S","R","S"]:
  print(int(1))
elif r ==["R","R","S"] or r==["S","R","R"]:
  print(int(2))
elif r==["S","S","S"]:
  print(int(0))
else:
  print(int(3))