while 1: a=input()*11 b=i=0 while a!=b:b=a.translate((b or a)[7:-23]);i+=1 print(i)