-- ABC116 B
import qualified Data.IntSet as IntSet
import Debug.Trace
import Data.Array

main :: IO ()
main = do
  s <- readLn :: IO Int
  print $ solve s

solve :: Int -> Int
solve s = find IntSet.empty [1..1000000]
  where
    a = listArray (1, 1000000) $ map g [1..1000000]
    f 1 = s
    f i | i `mod` 2 == 0 = i `div` 2
        | otherwise = 3 * i + 1
    g 1 = f 1
    g i = f $ a!(i-1)

    find :: IntSet.IntSet -> [Int] -> Int
    find ss (i:is)
      | IntSet.member fi ss =  i
      | otherwise = find (IntSet.insert fi ss) is
        where fi = a!i



