local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local d = io.read() d = lltonumber(d) local ans = d local function solve(x, rep) local ret = x for i = 1, rep do x = x / 2LL ret = ret + x end return ret end for i = 1, 64 do local min = 0LL local max = d while 1LL < max - min do local mid = (min + max) / 2LL if d <= solve(mid, i) then max = mid else min = mid end end if d == solve(max, i) then ans = max end end ans = tostring(ans):gsub("LL", "") print(ans)