s = input()

if s[0] == "S":
  if s[1] == "S":
    if s[2] == "S":
      print("0")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("1")
    else:
      print("2")
if s[0] == "R":
  if s[1] == "S":
    if s[2] == "S":
      print("1")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("2")
    else:
      print("3") s = input() s input() input if s[0] == "S":
  if s[1] == "S":
    if s[2] == "S":
      print("0")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("1")
    else:
      print("2") s[0] == "S" s[0] s 0 "S" if s[1] == "S":
    if s[2] == "S":
      print("0")
    else:
      print("1")
   s[1] == "S" s[1] s 1 "S" if s[2] == "S":
      print("0")
    else:
      print("1")
   s[2] == "S" s[2] s 2 "S" print("0") print "0" print("1") print "1" if s[1] == "R":
    if s[2] == "S":
      print("1")
    else:
      print("2") s[1] == "R" s[1] s 1 "R" if s[2] == "S":
      print("1")
    else:
      print("2") s[2] == "S" s[2] s 2 "S" print("1") print "1" print("2") print "2" if s[0] == "R":
  if s[1] == "S":
    if s[2] == "S":
      print("1")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("2")
    else:
      print("3") s[0] == "R" s[0] s 0 "R" if s[1] == "S":
    if s[2] == "S":
      print("1")
    else:
      print("1")
   s[1] == "S" s[1] s 1 "S" if s[2] == "S":
      print("1")
    else:
      print("1")
   s[2] == "S" s[2] s 2 "S" print("1") print "1" print("1") print "1" if s[1] == "R":
    if s[2] == "S":
      print("2")
    else:
      print("3") s[1] == "R" s[1] s 1 "R" if s[2] == "S":
      print("2")
    else:
      print("3") s[2] == "S" s[2] s 2 "S" print("2") print "2" print("3") print "3" s = input() input() s
s = input()

if s[0] == "S":
  if s[1] == "S":
    if s[2] == "S":
      print("0")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("1")
    else:
      print("2")
if s[0] == "R":
  if s[1] == "S":
    if s[2] == "S":
      print("1")
    else:
      print("1")
  if s[1] == "R":
    if s[2] == "S":
      print("2")
    else:
      print("3")