import qualified Data.IntMap.Strict as M
 
favo 1 = M.singleton 1 0
favo n
  | odd n = M.insert n 0 f
  | even n = M.insert n v f
    where
    f = favo $ n - 1
    v = f M.! (n `div` 2) + 1

main = do
  n <- readLn
  print .  foldr max 0 $ favo n