open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let rec atk num H = if H=1L then num else ((atk (num*2L) (H/2L))+num)
    R int64
    |>atk 1L
    |>stdout.WriteLine
    0