import Control.Applicative ((<$>))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  solve <$> getl (readi B.readInt) >>= print

solve :: Int -> Int
solve = f 0
  where
    f c x
      | x == 1 = c
      | even x = f (c + 1) (x `div` 2)
      | otherwise = f (c + 1) (x + 1)

getl :: (ByteString -> a) -> IO a
getl f = f <$> B.getLine

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n