At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$

We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, and so on, we'll eventually get $1$. Let's write down all values we get in this process in a list and denote this list as $path(v)$. For example, $path(1) = [1]$, $path(15) = [15, 14, 7, 6, 3, 2, 1]$, $path(32) = [32, 16, 8, 4, 2, 1]$.

Let's write all lists $path(x)$ for every $x$ from $1$ to $n$. The question is next: what is the maximum value $y$ such that $y$ is contained in at least $k$ different lists $path(x)$?

Formally speaking, you need to find maximum $y$ such that $\left| \{ x ~|~ 1 \le x \le n, y \in path(x) \} \right| \ge k$.


-----Input-----

The first line contains two integers $n$ and $k$ ($1 \le k \le n \le 10^{18}$).


-----Output-----

Print the only integer — the maximum value that is contained in at least $k$ paths.


-----Examples-----
Input
11 3

Output
5

Input
11 6

Output
4

Input
20 20

Output
1

Input
14 5

Output
6

Input
1000000 100

Output
31248



-----Note-----

In the first example, the answer is $5$, since $5$ occurs in $path(5)$, $path(10)$ and $path(11)$.

In the second example, the answer is $4$, since $4$ occurs in $path(4)$, $path(5)$, $path(8)$, $path(9)$, $path(10)$ and $path(11)$.

In the third example $n = k$, so the answer is $1$, since $1$ is the only number occuring in all paths for integers from $1$ to $20$.

Difficulty: HARD

Solutions:
def gg(n, lol):
	ans = 0
	cur = 1
	lol2 = lol
	while 2 * lol + 1 <= n:
		cur *= 2
		ans += cur
		lol = 2 * lol + 1
		lol2 *= 2
	if lol2 * 2 <= n:
		ans += n - lol2 * 2 + 1
	return ans
(n, k) = map(int, input().split())
low = 1
high = n // 2
res = 1
while low <= high:
	mid = (low + high) // 2
	if gg(n, mid) >= k:
		res = mid
		low = mid + 1
	else:
		high = mid - 1
if n == k:
	print(1)
elif gg(n, res) - 1 - gg(n, res * 2) >= k:
	print(res * 2 + 1)
else:
	print(res * 2)


from sys import stdin, stdout

def getmaxval(n, k):
	if n == k:
		return 1
	ol = 1
	oh = n // 2
	while ol < oh:
		om = (ol + oh + 1) // 2
		cnt = counteven(om * 2, n)
		if cnt >= k:
			ol = om
		else:
			oh = om - 1
	r1 = ol * 2
	if r1 < n:
		cnt2 = countodd(r1 + 1, n)
		if cnt2 >= k:
			return r1 + 1
	return r1

def counteven(b, n):
	res = 2
	inc = 2
	mv = b + 1
	while mv <= n:
		inc *= 2
		res += inc
		mv = b * inc // 2 + inc - 1
	if mv - inc <= n < mv:
		res -= mv - n
	elif n < mv - inc:
		res -= inc
	return res

def countodd(b, n):
	res = 1
	inc = 1
	mv = b
	while mv <= n:
		inc *= 2
		mv = b * inc + inc - 1
		res += inc
	if mv - inc <= n < mv:
		res -= mv - n
	elif n < mv - inc:
		res -= inc
	return res
nk = list(map(int, stdin.readline().split()))
n = nk[0]
k = nk[1]
res = getmaxval(n, k)
stdout.write(str(res))


(N, K) = [int(x) for x in input().split(' ')]

def f(x):
	(ret, i) = (0, 0)
	while x << i <= N:
		ret += min(N, (x << i) + (1 << i) - 1) - (x << i) + 1
		i += 1
	return ret
(lo, hi) = (1, N // 2)
while lo < hi:
	mi = (lo + hi + 1) // 2
	if f(2 * mi) + f(2 * mi + 1) >= K:
		lo = mi
	else:
		hi = mi - 1
if f(2 * lo) + f(2 * lo + 1) < K:
	lo = 0
(lo2, hi2) = (0, (N - 1) // 2)
while lo2 != hi2:
	mi2 = (lo2 + hi2 + 1) // 2
	if f(2 * mi2 + 1) >= K:
		lo2 = mi2
	else:
		hi2 = mi2 - 1
print(max(2 * lo, 2 * lo2 + 1))


(n, k) = map(int, input().split())
ans = 0
if n == k:
	ans = 1
elif k == 1:
	ans = n
else:
	p = 2
	s = 2
	while s < k:
		p *= 2
		s += p
	n1 = n
	n -= k
	ans = (n + p - 1) // p
	ans *= 2
	flag = False
	for i in range(1, 64):
		if 2 ** i - 1 == k:
			flag = True
	flag1 = False
	if flag and n1 % p == p - 1:
		ans += 1
print(ans)


import sys
reader = (map(int, line.split()) for line in sys.stdin)

def count(num):
	ans = 0
	if num % 2:
		add = 1
	else:
		add = 2
	while num + add - 1 <= n:
		ans += add
		add *= 2
		num *= 2
	if num <= n:
		ans += n - num + 1
	return ans

def func(n, k):
	if k == n:
		return 1
	L = 0
	R = n // 2 + n % 2
	while L + 1 < R:
		m = (L + R) // 2
		num = 2 * m + 1
		if count(num) >= k:
			L = m
		else:
			R = m
	m_odd = 2 * L + 1
	L = 1
	R = n // 2 + 1
	while L + 1 < R:
		m = (L + R) // 2
		num = 2 * m
		if count(num) >= k:
			L = m
		else:
			R = m
	m_even = 2 * L
	return max(m_odd, m_even)
(n, k) = next(reader)
ans = func(n, k)
print(ans)


def zip_sorted(a, b):
	return (zip(*sorted(zip(a, b)))[0], zip(*sorted(zip(a, b)))[1])

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def ncr(n, r):
	return math.comb(n, r)

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def decimal_to_binary(n):
	return bin(n).replace('0b', '')

def binary_to_decimal(s):
	return int(s, 2)
import sys, os.path
import math
from collections import defaultdict, deque
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input1()))

def binary_odd(x):
	pow1 = 0
	sum1 = 0
	while 2 ** pow1 * x <= n:
		if 2 ** pow1 * x + (2 ** pow1 - 1) <= n:
			sum1 += 2 ** pow1
		else:
			sum1 += n - 2 ** pow1 * x + 1
			break
		pow1 += 1
	return sum1 >= k

def binary_even(x):
	pow1 = 0
	sum1 = 0
	while 2 ** pow1 * x <= n:
		if 2 ** pow1 * x + (2 * 2 ** pow1 - 1) <= n:
			sum1 += 2 * 2 ** pow1
		else:
			sum1 += n - 2 ** pow1 * x + 1
			break
		pow1 += 1
	return sum1 >= k

def find_even_x(n1):
	start = 2
	end = n1
	ans = -1
	while start <= end:
		mid = (start + end) // 2
		if mid % 2 != 0:
			mid = mid + 1
		if binary_even(mid):
			ans = mid
			start = mid + 2
		else:
			end = mid - 2
	return ans

def find_odd_x(n1):
	start = 1
	end = n1
	ans = -1
	while start <= end:
		mid = (start + end) // 2
		if mid % 2 == 0:
			mid = mid + 1
		if binary_odd(mid):
			ans = mid
			start = mid + 2
		else:
			end = mid - 2
	return ans
t = 1
for t1 in range(t):
	(n, k) = I()
	if n % 2 == 0:
		x1 = find_even_x(n)
		x2 = find_odd_x(n - 1)
	else:
		x1 = find_even_x(n - 1)
		x2 = find_odd_x(n)
	if x1 == -1:
		print(x2)
	elif x2 == -1:
		print(x1)
	else:
		print(max(x1, x2))


(n, k) = map(int, input().split())

def check(m):
	if m % 2 == 0:
		ret = check(m + 1)
	else:
		ret = 0
	i = 0
	while True:
		if (m + 1 << i) - 1 <= n:
			ret += 1 << i
		elif m << i > n:
			break
		else:
			ret += n - (m << i) + 1
			break
		i += 1
	return ret
left = 0
right = n // 2 + 1
while right - left > 1:
	mid = (right + left) // 2
	if check(2 * mid) >= k:
		left = mid
	else:
		right = mid
ans = 2 * left
left = 0
right = (n + 1) // 2 + 1
while right - left > 1:
	mid = (right + left) // 2
	if check(2 * mid - 1) >= k:
		left = mid
	else:
		right = mid
ans = max(ans, 2 * left - 1)
print(ans)


(n, k) = map(int, input().split())
j = n
odd = 3
even = 6
if j % 2 == 0:
	n1 = 1
	n2 = 1
elif j % 2 != 0:
	n1 = 1
	n2 = 2
preodd = 1
preeven = 2
if k == n:
	print(1)
elif k == 1:
	print(j)
elif k == 2:
	if j % 2 == 0:
		print(j - 2)
	else:
		print(j - 1)
else:
	pre = n
	j = n // 2
	while j >= 1:
		if j % 2 == 0:
			if pre % 2 == 0:
				if n1 + preodd + 1 >= k:
					ans = j
					break
				elif odd >= k:
					ans = j - 1
					break
				elif even >= k and j > 4:
					ans = j - 2
					break
				else:
					n1 = n1 + preodd + 1
					n2 = odd
			elif n2 + preodd + 1 >= k:
				ans = j
				break
			elif odd >= k:
				ans = j - 1
				break
			elif even >= k and j > 4:
				ans = j - 2
				break
			else:
				n1 = n2 + preodd + 1
				n2 = odd
		elif pre % 2 != 0:
			if n2 + 1 >= k:
				ans = j
				break
			elif preeven + n2 + 2 >= k:
				ans = j - 1
				break
			elif odd >= k and j > 4:
				ans = j - 2
				break
			elif even >= k and j > 5:
				ans = j - 3
				break
			else:
				n1 = n2 + 1
				n2 = preeven + n2 + 2
		elif n1 + 1 >= k:
			ans = j
			break
		elif n1 + preeven + 2 >= k:
			ans = j - 1
			break
		elif odd >= k and j > 5:
			ans = j - 2
			break
		elif even >= k and j > 4:
			ans = j - 3
			break
		else:
			n1 = n1 + 1
			n2 = n1 + preeven + 2
		preodd = odd
		preeven = even
		odd = even + 1
		even = even + odd + 1
		pre = j
		j = j // 2
	print(ans)


(n, k) = map(int, input().split())

def c(m):
	a = b = m
	ans = 0
	if m % 2 == 0:
		b += 1
	while b <= n:
		ans += b - a + 1
		a *= 2
		b *= 2
		b += 1
	return ans + max(0, n - a + 1)
if n < 100:
	ans = 1
	for i in range(1, n + 1):
		if c(i) >= k:
			ans = i
	print(ans)
	return
for i in range(n, n - 100, -1):
	if c(i) >= k:
		print(i)
		return
ng = 0
ok = (n + 1) // 2 * 2
while ng + 2 != ok:
	mid = (ok + ng) // 4 * 2
	if c(mid) < k:
		ok = mid
	else:
		ng = mid
x = ng
ng = -1
ok = (n + 1) // 2 * 2 - 1
while ng + 2 != ok:
	mid = (ok + ng) // 4 * 2 + 1
	if c(mid) < k:
		ok = mid
	else:
		ng = mid
print(max(ng, x))


from math import log, ceil
(n, k) = map(int, input().split())
p = ceil(log(k + 2, 2)) - 1
m = 2 ** (p + 1) - 2 - k
ans = (n + m - (2 ** p - 1)) // 2 ** p * 2
ans2 = ans + 1
if 2 ** (p - 1) - 1 + min(n, ans2 * 2 ** (p - 1) + 2 ** (p - 1) - 1) - ans2 * 2 ** (p - 1) + 1 >= k:
	ans = ans2
print(max(ans, 1))


def _calc(prefix, n):
	if prefix > n:
		return 0
	prefix = bin(prefix)[2:]
	n = bin(n)[2:]
	plen = len(prefix)
	nlen = len(n)
	res = (1 << nlen - plen) - 1
	nprefix = n[:plen]
	if nprefix == prefix:
		for i in range(plen, nlen):
			if n[i] == '1':
				res += 1 << nlen - i - 1
		res += 1
	elif nprefix > prefix:
		res += 1 << nlen - plen
	return res

def calc(prefix, n):
	if prefix % 2 == 0:
		return _calc(prefix, n) + _calc(prefix + 1, n)
	return _calc(prefix, n)
(n, k) = map(int, input().split())
if n == k:
	print(1)
	exit(0)
ans = 1
(l, r) = (1, n >> 1)
while l < r:
	mid = l + r + 1 >> 1
	tot = calc(mid * 2, n)
	if tot >= k:
		l = mid
	else:
		r = mid - 1
l *= 2
if calc(l, n) >= k:
	ans = max(ans, l)
(l, r) = (0, n - 1 >> 1)
while l < r:
	mid = l + r + 1 >> 1
	tot = calc(mid * 2 + 1, n)
	if tot >= k:
		l = mid
	else:
		r = mid - 1
l = l * 2 + 1
if calc(l, n) >= k:
	ans = max(ans, l)
print(ans)


def main():
	(n, k) = inputi()

	def F(f):
		l = f if f % 2 else f + 1
		t = 0
		while l < n:
			t += l - f + 1
			l = l * 2 + 1
			f = f * 2
		return t + max(0, n - f + 1)
	odd = find_ge(range(1, n + 1, 2)[::-1], k, F, -inf)
	even = find_ge(range(2, n + 1, 2)[::-1], k, F, -inf)
	print(max(odd, even))
import builtins

def len(a):
	if isinstance(a, range):
		return -((a.start - a.stop) // a.step)
	return builtins.len(a)

def bisect_left(a, x, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	while lo < hi:
		mid = (lo + hi) // 2
		if key(a[mid]) < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def bisect_right(a, x, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	while lo < hi:
		mid = (lo + hi) // 2
		if x < key(a[mid]):
			hi = mid
		else:
			lo = mid + 1
	return lo

def insort_left(a, x, key=None, lo=0, hi=None):
	lo = bisect_left(a, x, key, lo, hi)
	a.insert(lo, x)

def insort_right(a, x, key=None, lo=0, hi=None):
	lo = bisect_right(a, x, key, lo, hi)
	a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right

def index(a, x, key=None, default=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	i = bisect_left(a, x, key, lo, hi)
	if lo <= i < hi and key(a[i]) == x:
		return a[i]
	if default != None:
		return default
	raise ValueError

def find_lt(a, x, key=None, default=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_left(a, x, key, lo, hi)
	if lo < i <= hi:
		return a[i - 1]
	if default != None:
		return default
	raise ValueError

def find_le(a, x, key=None, default=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_right(a, x, key, lo, hi)
	if lo < i <= hi:
		return a[i - 1]
	if default != None:
		return default
	raise ValueError

def find_gt(a, x, key=None, default=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_right(a, x, key, lo, hi)
	if lo <= i < hi:
		return a[i]
	if default != None:
		return default
	raise ValueError

def find_ge(a, x, key=None, default=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_left(a, x, key, lo, hi)
	if lo <= i < hi:
		return a[i]
	if default != None:
		return default
	raise ValueError
import sys, io, os
sys.setrecursionlimit(10000)
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().strip()
inputt = lambda t=0: range(t) if t else range(int(input()))
inputi = lambda : map(int, input().split())
inputl = lambda : list(inputi())
from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
import re, copy, operator, cmath
main()


import sys

def f(n, mid):
	(a, b, ans) = (1, mid, 0)
	while 2 * mid + 1 <= n:
		a *= 2
		ans += a
		mid = 2 * mid + 1
		b *= 2
	if 2 * b <= n:
		ans += n - 2 * b + 1
	return ans
(n, k) = map(int, input().split())
if n == k:
	print(1)
	sys.exit()
(low, high, m) = (0, n // 2, 1)
while low <= high:
	mid = low + (high - low) // 2
	x = f(n, mid)
	if x >= k:
		m = mid
		low = mid + 1
	else:
		high = mid - 1
if f(n, m) - 1 - f(n, 2 * m) >= k:
	print(2 * m + 1)
else:
	print(2 * m)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, k) = sep()
	l = 1
	h = n
	ans = 0
	while h >= l:
		i = (l + h) // 2
		i *= 2
		cnt = 0
		if i % 2 == 1:
			curr = [i, i]
			cnt = 1
		else:
			curr = [i, i + 1]
			cnt = 2
		while 2 * curr[1] + 1 < n:
			curr = [curr[0] * 2, curr[1] * 2 + 1]
			cnt += curr[1] - curr[0] + 1
		if curr[0] * 2 < n:
			cnt += n - curr[0] * 2 + 1
		if i > n:
			cnt = 0
		if cnt >= k:
			l = i // 2 + 1
			ans = i
		else:
			h = i // 2 - 1
	l = 1
	h = n
	ans1 = 0
	while h >= l:
		i = (l + h) // 2
		i *= 2
		i -= 1
		cnt = 0
		if i % 2 == 1:
			curr = [i, i]
			cnt = 1
		else:
			curr = [i, i + 1]
			cnt = 2
		while 2 * curr[1] + 1 < n:
			curr = [curr[0] * 2, curr[1] * 2 + 1]
			cnt += curr[1] - curr[0] + 1
		if curr[0] * 2 < n:
			cnt += n - curr[0] * 2 + 1
		if i > n:
			cnt = 0
		if cnt >= k:
			l = (i + 1) // 2 + 1
			ans1 = i
		else:
			h = (i + 1) // 2 - 1
	print(max(ans, ans1))
testcase(1)


(a, N, K) = [0] + [int(i) for i in input().split()]
d = lambda n: sum([min(N - (n << e) + 1, 1 << e) for e in range(99) if n << e <= N])
c = lambda n: d(n) + (d(n + 1), 0)[n & 1]
for b in range(59, -1, -1):
	a += (0, 1 << b)[c(a + 2 ** b) >= K]
print(a)


(n, k) = [int(x) for x in input().split()]

def DTB(num, x):
	if num > 1:
		DTB(num // 2, x)
	x.append(num % 2)
nn = []
kk = []
DTB(n, nn)
DTB(k, kk)
if k == 1:
	print(n)
elif k == 2:
	if n == 2:
		print(1)
	elif n % 2 == 0:
		print(n - 2)
	else:
		print(n - 1)
elif k == 3:
	if n % 4 == 2:
		print(n // 2 - 1)
	else:
		print(n // 2)
else:
	a = len(kk) - 2
	m = len(nn)
	p = 2 ** (a + 1) - 1 + n % 2 ** a
	if nn[m - a - 1] == 1:
		p += 2 ** a
	if p >= k:
		print(int(''.join([str(x) for x in nn[0:m - a - 1]]) + '0', 2))
	else:
		N = nn[0:m - a - 1]
		if sum(N) > 1:
			if k == 2 ** (a + 2) - 1:
				if sum(nn[m - a - 1:m]) == a + 1:
					print(int(''.join([str(x) for x in nn[0:m - a - 1]]), 2))
				else:
					print(int(''.join([str(x) for x in nn[0:m - a - 2]]) + '0', 2))
			else:
				N.reverse()
				ind = N.index(1)
				N[ind] = 0
				for i in range(ind):
					N[i] = 1
				N.reverse()
				N.append(0)
				print(int(''.join([str(x) for x in N]), 2))
		elif m - a - 1 == 1:
			print(1)
		elif k != 2 ** (a + 2) - 1:
			print(2 ** (m - a - 1) - 2)
		else:
			print(2 ** (m - a - 2))


(N, K) = map(int, input().split())

def even(a):
	if a == 0:
		return True
	n = 2 * a
	res = 0
	m = n.bit_length()
	M = N.bit_length()
	for i in range(60):
		if i + m < M:
			res += 2 ** (i + 1)
		elif i + m == M:
			if N >> i > n:
				res += 2 ** i
			elif N >> i == n:
				res += N - (n << i) + 1
			if N >> i > n + 1:
				res += 2 ** i
			elif N >> i == n + 1:
				res += N - (n + 1 << i) + 1
			break
	return res >= K

def odd(a):
	n = 2 * a - 1
	res = 0
	m = n.bit_length()
	M = N.bit_length()
	for i in range(60):
		if i + m < M:
			res += 2 ** i
		elif i + m == M:
			if N >> i > n:
				res += 2 ** i
			elif N >> i == n:
				res += N - (n << i) + 1
			break
	return res >= K
start = 0
end = 10 ** 18
while end - start > 1:
	t = (end + start) // 2
	if even(t):
		start = t
	else:
		end = t
test1 = -1
if even(end):
	test1 = 2 * end
else:
	test1 = 2 * start
start = 1
end = 10 ** 18
while end - start > 1:
	t = (end + start) // 2
	if odd(t):
		start = t
	else:
		end = t
test2 = -1
if odd(end):
	test2 = 2 * end - 1
else:
	test2 = 2 * start - 1
print(max(test1, test2))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

def full(x, n):
	if n + 1 & n != 0:
		raise Exception('qwe')
	r = 1
	while True:
		if r >= x:
			return n
		if n == 1:
			return None
		r *= 2
		n -= 1
		if r >= x:
			return n
		n //= 2
		r += 1

def is_good(x, n):
	l = x
	r = x
	rp = x
	if x % 2 == 0:
		return None
	while l <= n:
		if l <= n and r > n:
			return None
		l *= 2
		rp = r
		r = r * 2 + 1
	return rp

def full2(x, c, rp):
	r = 1
	while True:
		if r >= x:
			return rp
		if rp == c:
			return None
		r *= 2
		rp -= 1
		if r >= x:
			return rp
		rp //= 2
		r += 1
	return None

def full1(k, x, n):
	rp = is_good(x, n)
	if rp == None:
		r = None
		if f(x, n) >= k:
			r = x
		if 2 * x <= n:
			r1 = full1(k, 2 * x, n)
			if r1 != None and (r == None or r < r1):
				r = r1
		if 2 * x + 1 <= n:
			r1 = full1(k, 2 * x + 1, n)
			if r1 != None and (r == None or r < r1):
				r = r1
		return r
	else:
		return full2(k, x, rp)

def fulls(k, n):
	r = 1
	for i in range(1, n + 1):
		if f(i, n) >= k:
			r = i
	return r

def f(x, n):
	r = 0
	rp = is_good(x, n)
	if rp != None:
		r = 1
		while rp != x:
			r = r * 2 + 1
			rp //= 2
		return r
	if x <= n:
		r += 1
	if x % 2 == 0 and x + 1 <= n:
		r += f(x + 1, n)
	if 2 * x <= n:
		r += f(x * 2, n)
	return r

def f1(x, n):
	r = 0
	if x <= n:
		r += 1
	if x % 2 == 0 and x + 1 <= n:
		r += f(x + 1, n)
	if 2 * x <= n:
		r += f(x * 2, n)
	return r
(n, k) = mints()
print(full1(k, 1, n))


import sys
input = sys.stdin.readline
(N, K) = map(int, input().split())

def search(odd_num):
	c = 0
	upper = odd_num
	down = odd_num
	while upper <= N:
		c += upper - down + 1
		upper = 2 * upper + 1
		down = 2 * down
	if down <= N:
		c += N - down + 1
	return c

def binary_search(maximum, odd):
	l = 0
	r = maximum + 2
	while r - l > 1:
		m = (r + l) // 2
		num = 2 * m + 1 if odd else 2 * m
		if odd:
			count = search(num)
		else:
			count = search(num // 2) - 1
		if count >= K:
			l = m
		else:
			r = m
	return 2 * l + 1 if odd else 2 * l
a1 = binary_search((N + 1) // 2, odd=True)
a2 = binary_search((N + 1) // 2, odd=False)
print(max(a1, a2))


(n, k) = map(int, input().split())

def calc(z):
	global n
	if z > n:
		return False
	if z == 0:
		return True
	if z % 2 == 1:
		ans = 1
		now = 2 * z
		co = 1
		if k == 1:
			return True
		elif now > n:
			return False
	else:
		ans = 0
		now = z
		co = 1
	while True:
		if n <= now + 2 * co - 1:
			ans += max(0, n - now + 1)
			break
		else:
			now *= 2
			co *= 2
			ans += co
	return ans >= k
realans = []
l = 1
r = n // 2 + 2
while l + 1 < r:
	y = l + (r - l) // 2
	if calc(2 * y - 1):
		l = y
	else:
		r = y
realans.append(2 * l - 1)
l = 0
r = n // 2 + 2
while l + 1 < r:
	y = l + (r - l) // 2
	if calc(2 * y):
		l = y
	else:
		r = y
realans.append(2 * l)
print(max(realans))


def c(x):
	global n
	a = b = x
	if x % 2 == 0:
		b += 1
	res = b - a + 1
	while 2 * b < n:
		a = 2 * a
		b = 2 * b + 1
		res += b - a + 1
	if 2 * a <= n:
		res += n - 2 * a + 1
	return res
(n, k) = map(int, input().split())
cnt = 0
l = 0
r = n // 2 + 1
while r - l > 1:
	m = (r + l) // 2
	cnt = c(2 * m)
	if cnt >= k:
		l = m
	else:
		r = m
maxl = 2 * l
l = 0
r = (n + 1) // 2
while r - l > 1:
	m = (r + l) // 2
	cnt = c(2 * m + 1)
	if cnt >= k:
		l = m
	else:
		r = m
maxl = max(maxl, 2 * l + 1)
print(maxl)


(n, k) = list(map(int, input().split()))
s = bin(n)[2:]
ans = 1
if k == 1:
	ans = n
else:
	f = len(s)
	for d in range(1, f):
		rgt = int(s[-d:], 2)
		lft = int(s[:-d], 2)
		c = 2 ** d
		if rgt + c >= k:
			if rgt + c > k:
				ans = max(lft * 2, ans)
			else:
				ans = max(lft, ans)
		if 2 * c - 1 >= k:
			if 2 * c - 1 > k:
				ans = max((lft - 1) * 2, ans)
			else:
				ans = max(lft - 1, ans)
print(ans)


(n, k) = map(int, input().split())

def solve(n, num):
	ans = 0
	keta_num = num.bit_length()
	keta_n = n.bit_length()
	keta_diff = keta_n - keta_num
	if keta_diff < 0:
		return ans
	ans += (1 << keta_diff) - 1
	if n >> keta_diff > num:
		ans += 1 << keta_diff
	elif n >> keta_diff == num:
		ans += n & (1 << keta_diff) - 1
		ans += 1
	return ans
ok = 0
ng = n + 10
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	val = mid * 2 + 1
	if solve(n, val) >= k:
		ok = mid
	else:
		ng = mid
ans1 = ok * 2 + 1
ok = 0
ng = n + 10
while abs(ok - ng) > 1:
	mid = (ok + ng) // 2
	val = mid * 2
	if solve(n, val) + solve(n, val + 1) >= k:
		ok = mid
	else:
		ng = mid
ans2 = ok * 2
print(max(ans1, ans2))


def ans(m, n):
	(q1, q2, k) = (m, 2, 0)
	while q1 <= n:
		q1 *= 2
		k += q2
		q2 *= 2
	q2 //= 2
	q1 //= 2
	if n - q1 < q2:
		return k + n - q1 - q2 + 1
	return k
(n, k) = list(map(int, input().split()))
if k == n:
	print(1)
elif k == 1:
	print(n)
else:
	(l, r) = (1, n // 2 + 1)
	while r - l > 1:
		m = (l + r) // 2
		if ans(2 * m, n) >= k:
			l = m
		else:
			r = m
	(l1, r1) = (1, n // 2 + 1)
	while r1 - l1 > 1:
		m = (l1 + r1) // 2
		if ans(2 * m, n) >= k - 1:
			l1 = m
		else:
			r1 = m
	print(max(l1, 2 * l))


(n, k) = map(int, input().split())
p = 1
w = 0
while p * 2 <= k:
	p *= 2
	w += 1
kk = k - p
odd = (n - kk) // 2 ** w
if odd % 2 == 0:
	odd -= 1
p = 1
w = 0
while 2 * (2 * p - 1) < k:
	p *= 2
	w += 1
poz = k - 2 * (p - 1)
if poz == 0:
	even = (n - (2 ** w - 1)) // 2 ** (w - 1)
	if even % 2 == 1:
		even -= 1
else:
	if poz <= p * 4343:
		strzal = (n + 1 - poz) // p
		if strzal % 2 == 1:
			strzal -= 1
	even = strzal
print(max(even, odd))


(a, b) = input().split()
a = int(a)
b = int(b)
if b == 1:
	print(a)
elif b == 2:
	if a % 2 == 0:
		print(a // 2)
	else:
		print(a - 1)
else:
	chopped_even = bin(b + 1)[3:]
	len_even = len(chopped_even)
	best_even = (a - int(chopped_even, 2)) // 2 ** len_even * 2
	chopped_odd = bin(b)[2:]
	len_odd = len(chopped_odd)
	best_odd = (a - b) // 2 ** len_odd * 2 + 1
	if best_even > best_odd:
		print(best_even)
	else:
		print(best_odd)


import sys
input = sys.stdin.readline
(n, k) = [int(item) for item in input().split()]
possible = set()
t = n
while t > 1:
	possible.add(t)
	possible.add(t - 1)
	possible.add(t - 2)
	possible.add(t - 3)
	t //= 2
if 0 in possible:
	possible.remove(0)
possible.add(1)
possible = sorted(list(possible), reverse=True)
for i in possible:
	ret = 0
	l = i
	r = l + 1 + (l % 2 == 0)
	while l <= n:
		ret += min(r, n + 1) - l
		l <<= 1
		r <<= 1
	if ret >= k:
		print(i)
		exit()


import sys

def cnt(y, n):
	if y <= 1:
		return n
	if y > n:
		return 0
	if y % 2 == 1:
		return 1 + cnt(2 * y, n)
	c = 0
	p = 1
	while p * y <= n:
		mx = min(n, p * y + 2 * p - 1)
		c += mx - p * y + 1
		p *= 2
	return c
(n, k) = input().split()
(n, k) = (int(n), int(k))
if k == 1:
	print(n)
	sys.exit(0)
(l, h) = (1, n // 2)
while l < h:
	m = (l + h) // 2
	if cnt(2 * m, n) < k:
		h = m
	else:
		l = m + 1
mx_even = 2 * l - 2
(l, h) = (1, n // 2)
while l < h:
	m = (l + h) // 2
	if cnt(2 * m + 1, n) < k:
		h = m
	else:
		l = m + 1
mx_odd = 2 * l - 1
mx_heur = -1
i = 0
while i < 20 and n - i > 0:
	if cnt(n - i, n) >= k:
		mx_heur = n - i
		break
	i += 1
print(max(mx_even, max(mx_odd, mx_heur)))


import random
import math

def function(x):
	if x % 2 == 0:
		return int(x / 2)
	else:
		return x - 1

def solve_1(n, k):
	frequency = [0] * n
	frequency[0] = n
	for i in range(1, n + 1):
		path(i, frequency)
	max = 1
	for i in range(n):
		if frequency[i] >= k:
			max = i + 1
	return max

def path(n, frequency):
	while n > 1:
		frequency[n - 1] += 1
		n = function(n)
	return

def solve_2(n, k):
	max_even = binary_search(n, k, 0, n, 0)
	max_odd = binary_search(n, k, 0, n, 1)
	return max(max_even, max_odd)

def binary_search(n, k, l, r, parity):
	max_contained = 0
	if n == k:
		return 1
	while r - l > 1:
		m = (r + l) // 2
		if m % 2 == (not parity):
			m += 1
		if not parity:
			count = calculate_count_even(n, m)
		else:
			count = calculate_count_odd(n, m)
		if count >= k:
			max_contained = max(max_contained, m)
			l = m
		else:
			r = m - 2
	return max_contained

def calculate_count_odd(n, x):
	if x == 1:
		return n
	(count, a) = (0, 1)
	while a * x <= n:
		p = a * x + (a - 1)
		if p <= n:
			count += a
			a *= 2
		else:
			count += n - a * x + 1
			break
	return count

def calculate_count_even(n, x):
	if x == 2:
		return n - 1
	(count, a) = (1, 2)
	if x + 1 <= n:
		count += 1
	while a * x <= n:
		p = a * x + (2 * a - 1)
		if p <= n:
			count += 2 * a
			a *= 2
		else:
			count += n - a * x + 1
			break
	return count

def main():
	(n, k) = [int(i) for i in input().split()]
	print(solve_2(n, k))
	return

def random_cases():
	case = [0] * 2
	case_generator(case)
	print('Case: \n' + 'n = ' + str(case[0]) + '  ' + 'k = ' + str(case[1]))
	print(solve_2(case[0], case[1]))
	return

def case_generator(case):
	case[0] = random.randint(1, 1000)
	case[1] = random.randint(1, case[0])
	return

def tester():
	for i in range(1, 20):
		case = [0] * 2
		case_generator(case)
		s1 = solve_1(case[0], case[1])
		s2 = solve_2(case[0], case[1])
		print('Case ' + str(i) + ':\n' + 'n = ' + str(case[0]) + '   k = ' + str(case[1]))
		print('solucion fuerza bruta : ' + str(s1))
		print('solucion eficiente : ' + str(s2))
		if s1 != s2:
			print('Wrong Answer\n')
			return
		print('Accepted\n')
	return
main()


import os, sys, math
import collections
if os.path.exists('testing'):
	name = os.path.basename(__file__)
	if name.endswith('.py'):
		name = name[:-3]
	src = open(name + '.txt', encoding='utf8')
	input = src.readline

def solve():

	def count_rec(fr, to):
		if n < fr:
			return 0
		if fr <= n <= to:
			return n - fr + 1
		return to - fr + 1 + count_rec(fr * 2, to * 2 + 1)

	def count(x):
		if x & 1:
			return count_rec(x, x)
		return count_rec(x, x + 1)

	def binary_search(fr, to, o):
		if fr == to:
			return fr * 2 + o
		s = (fr + to) // 2
		v = count(s * 2 + 2 + o)
		if v >= k:
			return binary_search(s + 1, to, o)
		return binary_search(fr, s, o)
	v1 = binary_search(0, n // 2, 0)
	v2 = binary_search(0, n // 2, 1)
	return max(v1, v2)

def integers():
	return map(int, input().strip().split())

def array_of_integers(q):
	return [tuple(map(int, input().strip().split())) for _ in range(q)]
(n, k) = integers()
res = solve()
print(res)


import sys

def cnt(x):
	c = 0
	for i in range(65):
		if int(x) << i > n:
			break
		if x & 1:
			c += min(int(1) << i, n - (x << i) + 1)
		else:
			c += min(int(1) << i + 1, n - (x << i) + 1)
	return c
(n, k) = [int(x) for x in input().split()]
if k == 1:
	print(n)
	sys.exit(0)
l = 1
r = n + 1
while r - l > 1:
	m = (r + l) // 2
	if cnt(m * 2 - 1) >= k:
		l = m
	else:
		r = m
ans1 = 2 * l - 1
l = 0
r = n + 1
while r - l > 1:
	m = (l + r) // 2
	if cnt(m * 2) >= k:
		l = m
	else:
		r = m
ans2 = 2 * l
ans = max(ans1, ans2)
print(ans)
sys.exit(0)


(n, k) = [int(x) for x in input().split()]

def chg(n):
	lis = []
	for i in range(100):
		if 2 ** i > n:
			break
		lis.append((n & 2 ** i) >> i)
	return lis

def calc(x):
	cnt = 0
	k = 1
	if x % 2 == 0:
		x = x // 2
		cnt = -1
	while k * x <= n:
		cnt += min(k * x + k - 1, n) - k * x + 1
		k *= 2
	return cnt
l = 1
r = n
while l < r:
	mid = l + r + 1 >> 1
	if calc(2 * mid - 1) >= k:
		l = mid
	else:
		r = mid - 1
ans = 2 * l - 1
l = 1
r = n
while l < r:
	mid = l + r + 1 >> 1
	if calc(2 * mid) >= k:
		l = mid
	else:
		r = mid - 1
if calc(2 * l) >= k:
	ans = max(ans, 2 * l)
print(ans)


(n, k) = map(int, input().split())
left = 0
right = 10 ** 18 + 2
p = [2 ** i for i in range(61)]
while right - left > 2:
	mid = (right + left) // 2
	mid -= mid % 2
	l = 0
	r = 60
	if mid > n:
		right = mid
		continue
	while r - l > 1:
		m = (r + l) // 2
		if mid * p[m] <= n:
			l = m
		else:
			r = m
	cur = 0
	cur += p[l + 1] - 2 + min(n - p[l] * mid + 1, p[l + 1])
	if cur < k:
		right = mid
	else:
		left = mid
x = left
left = 1
right = 10 ** 18 + 1
while right - left > 2:
	mid = (right + left) // 2
	if mid % 2 == 0:
		mid += 1
	l = 0
	r = 60
	if mid > n:
		right = mid
		continue
	while r - l > 1:
		m = (r + l) // 2
		if mid * p[m] <= n:
			l = m
		else:
			r = m
	cur = 0
	cur += min(n - p[l] * mid + 1, p[l]) + p[l] - 1
	if cur < k:
		right = mid
	else:
		left = mid
print(max(left, x))


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def find1(x):
	cur = 0
	for j in range(60):
		if pow(2, j) * x + pow(2, j + 1) - 1 <= n:
			cur += pow(2, j + 1)
		else:
			cur += max(0, n - pow(2, j) * x + 1)
			return cur

def find2(x):
	cur = 0
	for j in range(60):
		if pow(2, j) * x + pow(2, j) - 1 <= n:
			cur += pow(2, j)
		else:
			cur += max(0, n - pow(2, j) * x + 1)
			return cur
(n, k) = map(int, input().split())
low = 1
high = n // 2
while low <= high:
	mid = (low + high) // 2
	c = find1(2 * mid)
	if c >= k:
		low = mid + 1
	else:
		high = mid - 1
ans = 2 * high
low = 1
high = (n + 1) // 2
while low <= high:
	mid = (low + high) // 2
	c = find2(2 * mid - 1)
	if c >= k:
		low = mid + 1
	else:
		high = mid - 1
ans = max(ans, 2 * high - 1)
print(ans)


def binary_search(lb, ub, criterion):
	ok = lb
	ng = ub
	while ng - ok > 1:
		mid = (ng + ok) // 2
		if criterion(mid):
			ok = mid
		else:
			ng = mid
	return ok
(n, k) = list(map(int, input().split()))
odd_acc_count = 0
odd_count = 1
depth = 0
while odd_acc_count < k:
	odd_acc_count += odd_count
	odd_count *= 2
	depth += 1
residual = k - (odd_acc_count - odd_count // 2) - 1
odd_max_idx = binary_search(0, n + 2, lambda x: (2 * x + 1) * (1 << depth - 1) + residual <= n)
ans_odd = 2 * odd_max_idx + 1
even_acc_count = 0
even_count = 2
depth = 0
while even_acc_count < k:
	even_acc_count += even_count
	even_count *= 2
	depth += 1
residual = k - (even_acc_count - even_count // 2) - 1
even_max_idx = binary_search(0, n + 2, lambda x: 2 * x * (1 << depth - 1) + residual <= n)
ans_even = 2 * even_max_idx
print(max(ans_odd, ans_even))


def check(md, n, k):
	s = 0
	(temp, i) = (md, 1)
	while temp <= n:
		s += min(n - temp + 1, i)
		temp *= 2
		i *= 2
	if md % 2 == 0:
		(temp, i) = (md + 1, 1)
		while temp <= n:
			s += min(n - temp + 1, i)
			temp *= 2
			i *= 2
	if s >= k:
		return True
	return False
(n, k) = map(int, input().split())
(l, r) = (0, n // 2 + 1)
while r - l > 1:
	md = (l + r) // 2
	if check(2 * md, n, k) == True:
		l = md
	else:
		r = md
even = 2 * l
(l, r) = (0, n // 2 + 1)
while r - l > 1:
	md = (l + r) // 2
	if check(2 * md + 1, n, k) == True:
		l = md
	else:
		r = md
odd = 2 * l + 1
print(max(even, odd))


(n, k) = map(int, input().split())
if n == k:
	print(1)
	exit(0)

def calc(x):
	ans = 1
	if x % 2 == 1:
		t = x
		while True:
			x *= 2
			t = 2 * t + 1
			if x > n:
				break
			ans += min(t, n) - x + 1
	elif x + 1 <= n:
		t = x + 1
		ans += 1
		while True:
			x *= 2
			t = 2 * t + 1
			if x > n:
				break
			ans += min(t, n) - x + 1
	return ans
l = 1
ans = 0
if n % 2 == 0:
	r = n - 1
else:
	r = n
while True:
	if l == r:
		ans = l
		break
	if l == r - 1:
		if l % 2 == 1:
			ans = l
		else:
			ans = r
		break
	m = (l + r) // 2
	if m % 2 == 0:
		m += 1
	tt = calc(m)
	if tt >= k:
		l = m
	else:
		r = m - 1
l = 2
if n % 2 == 0:
	r = n
else:
	r = n - 1
while True:
	if l == r:
		anss = l
		break
	if l == r - 1:
		if l % 2 == 0:
			anss = l
		else:
			anss = r
		break
	m = (l + r) // 2
	if m % 2 == 1:
		m += 1
	tt = calc(m)
	if tt >= k:
		l = m
	else:
		r = m - 1
print(max(anss, ans))


from collections import defaultdict
(n, k) = [int(x) for x in input().split()]

def f(x):
	res = 1
	if x % 2 == 1:
		adj = 1
	else:
		adj = 2
	res = adj
	i = 2
	while i * x <= n:
		if i * x + adj * i - 1 <= n:
			res += i * adj
			i *= 2
		else:
			res += n - i * x + 1
			break
	return res

def find():
	lo = 1
	hi = n // 2
	re = 1
	while lo <= hi:
		m = (lo + hi) // 2
		if f(2 * m) >= k:
			re = 2 * m
			lo = m + 1
		else:
			hi = m - 1
	lo = 1
	hi = n // 2 + n % 2
	ro = 1
	while lo <= hi:
		m = (lo + hi) // 2
		if f(2 * m - 1) >= k:
			ro = 2 * m - 1
			lo = m + 1
		else:
			hi = m - 1
	return max(re, ro)
print(find())