import Control.Monad (unless)

collatz :: Integral a => a -> [a]
collatz = takeWhile (> 0) . iterate f
    where
        f 1 = 0
        f x
            | even x = div x 2
            | otherwise = 3 * x + 1

main :: IO ()
main = do
    n <- readLn
    unless (n == 0) $ do
        print $ pred $ subtract 1 $ collatz n
        main