program main
   implicit none
   integer s1
   integer:: s(1000000)
   integer i,j
   read(*,*)s1
   s(1)=s1
   do i=1,1000000
      if(mod(s(i),2)==0)then
         s(i+1)=s(i)/2
      else
         s(i+1)=3*s(i)+1
      endif
      do j=1,i
         if(s(i+1)==s(j))then
            write(*,*)i+1
            goto 100
         endif
      enddo
   enddo
100 continue
end program main
