import Data.List (findIndex)
import Data.Maybe (fromJust)

main = (+2) . fromJust . solve <$> readLn >>= print

solve a = findIndex f $ fmap (`take` collatz a) [2..]
    where
        f x = let y = reverse x in head y `elem` tail y

collatz a = fmap ($ a) <$> scanl (.) id $ repeat f
    where
        f n | even n = div n 2
            | otherwise = 3*n+1