import Control.Monad import Control.Applicative import Data.List main = do t <- readLn putStrLn $ show $ solve t solve :: Int -> Int solve n = numx n + (lastx $ n - (2 ^ (numx n))) numx :: Int -> Int numx n = (floor (logBase 2 (fromIntegral n))) lastx :: Int -> Int lastx 0 = 0 lastx 1 = 1 lastx n | (mod n 2) == 0 = 1 | otherwise = 2