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 x = io.read()
x = lltonumber(x)

for i = -300, 300 do
  local v = x + i
  if v <= 1LL then v = 1LL end
  local c = 0
  local tv = v
  for j = 1, 60 do
    if tv % 2LL == 1LL then c = c + 1 end
    tv = tv / 2LL
  end
  local mul = 1LL
  local ret = 0LL
  tv = v
  for j = 1, 60 do
    if tv % 2LL ~= c % 2LL then
      ret = ret + mul
    end
    tv = tv / 2LL
    c = c / 2LL
    mul = mul * 2LL
  end
  if ret == x then
    local a = tostring(v):gsub("LL", "")
    print(a)
    os.exit()
  end
end
print(-1)