import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Data.Vector.Unboxed (Vector, (!))
import qualified Data.Vector.Unboxed as U
import Data.Vector.Unboxed.Mutable (unsafeRead, unsafeWrite)
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
  [s] <-  readInts
  --let result = vectest input
  --print result
  print $ solve s

solve :: Int -> Int
solve s = result ! 0
  where
    result = U.create $ do
      v <- UM.replicate 1000001 0
      unsafeWrite v s 1
      loop v s 1
      return v
      where
        f n = if even n then (n `div` 2) else (3 * n + 1)
        loop v a i = do
          let nexta = f a
          let nexti = i + 1
          x <- unsafeRead v nexta
          if x == 0
            then do
              unsafeWrite v nexta nexti
              loop v nexta nexti
            else do
              unsafeWrite v 0 nexti
              return ()

vectest :: Vector Int -> Vector Int
vectest input = U.create $ do
  v <- UM.replicate 1000 0
  forM_ [0 .. 999] (\i -> do
    let e = input ! i
    unsafeWrite v i e
    )
  return v

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body