Since Grisha behaved well last year, at New Year's Eve he was visited by Ded Moroz who brought an enormous bag of gifts with him! The bag contains n sweet candies from the good ol' bakery, each labeled from 1 to n corresponding to its tastiness. No two candies have the same tastiness.

The choice of candies has a direct effect on Grisha's happiness. One can assume that he should take the tastiest ones — but no, the holiday magic turns things upside down. It is the xor-sum of tastinesses that matters, not the ordinary sum!

A xor-sum of a sequence of integers a_1, a_2, ..., a_{m} is defined as the bitwise XOR of all its elements: $a_{1} \oplus a_{2} \oplus \ldots \oplus a_{m}$, here $\oplus$ denotes the bitwise XOR operation; more about bitwise XOR can be found here.

Ded Moroz warned Grisha he has more houses to visit, so Grisha can take no more than k candies from the bag. Help Grisha determine the largest xor-sum (largest xor-sum means maximum happiness!) he can obtain.


-----Input-----

The sole string contains two integers n and k (1 ≤ k ≤ n ≤ 10^18).


-----Output-----

Output one number — the largest possible xor-sum.


-----Examples-----
Input
4 3

Output
7

Input
6 6

Output
7



-----Note-----

In the first sample case, one optimal answer is 1, 2 and 4, giving the xor-sum of 7.

In the second sample case, one can, for example, take all six candies and obtain the xor-sum of 7.

Difficulty: interview

Starter code:

Solutions:
R=lambda:list(map(int,input().split()))
n,k=R()
if k==1:print(n)
else:
    i=0
    while (1<<i)<=n:i+=1
    print((1<<i)-1)


n, k = map(int, input().split())
if k == 1:
    print(n)
else:
    j = 1
    while j - 1 < n:
        j *= 2
    print(j - 1)

from sys import stdin, stdout

n,k = list(map(int, stdin.readline().rstrip().split()))

if k==1:
    print(n)
else:
    x=1
    while 2*x<=n:
        x*=2
    print(2*x-1)



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

if K == 1:
    print(N)
else:
    cnt = 0
    while N > 0:
        N >>= 1
        cnt += 1
    print((1<<cnt)-1)


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

if k == 1:
    print(n)
else:
    nn = n
    p = 0
    while nn:
        nn //= 2
        p += 1
    print(2**p - 1)


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

if k == 1:
	print(n)
else:
	bin_n = bin(n)[2:]
	max_deg = len(bin_n)
	print((1 << (max_deg)) - 1)


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

r = 0
nn = n
while nn:
    nn >>= 1
    r += 1

print((1<<r)-1 if k>1 else n)


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

if k == 1:
    print(n)
else:
    print(int('1' * len(bin(n)[2:]), 2))


n,k = list(map(int, input().split(' ')))
x = 1
while x < n:
    x *= 2

if x > n:
    x //= 2

if k > 1:
    print(x + x - 1)
if k == 1:
    print(n)


n, k = map(int, input().split())
if k == 1:
    print(n)
    return
ans = 1
while 2**ans <= n:
    ans += 1
ans = 2**ans - 1
print(ans)

def problemB():
    n, k = list(map(int, input().strip().split()))
    if k == 1:
        print(n)
    else:
        bas = 1
        while n > 0:
            n //=2
            bas *=2
        print(bas-1)


def __starting_point():
    problemB()

__starting_point()

def read():
    return list(map(int,input().split()))
n,k=read()
if k==1:
    print(n)
else:
    ans=0
    for i in range(len(bin(n)[2:])):
        ans+=2**i
    print(ans)
        
        


import sys
sys.setrecursionlimit(1000000)
read = sys.stdin.readline

N, K = map(int, read().split())
if K == 1:
    print(N)
    return
allOne = 1
while((allOne<<1) <= N):
    allOne <<= 1
allOne<<=1
allOne -= 1
print(allOne)

import sys
import itertools
import functools

def brute_exact(n, k):
    ar = list(range(1, n + 1))
    combinations = list(itertools.combinations(ar, k))
    if not combinations:
        return 0
    
    xor_conv = lambda ar: functools.reduce(lambda x,y : x^y, ar)
    return max([xor_conv(combination) for combination in combinations]) 

def brute_atleast(n, k):
    return max([brute_exact(n, i) for i in range(1, k + 1)])

def solve(n, k):
    if k == 1:
        return n
    
    return 2**(n.bit_length()) - 1

def main():
    n, k = list(map(int, input().split()))
    print(solve(n, k))
	
def __starting_point():
    main() 
    

__starting_point()

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

if k == 1:
	print(n)
else:
	pr = 1;
	while (pr <= n):
		pr *= 2
	print(pr - 1)

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

else:
	num = 1
	while num <= n:
		num <<= 1

	print(num-1)

n, k = list(map(int, input().split()))
if k == 1:
    print(n)
else:
    ans = bin(n)[2:]
    ans = ans.replace("0", "1")
    ans = int(ans, 2)
    print(ans)


n,k=map(int,input().split())
if k==1:
  print(n)
else:
  bits=len(bin(n)[2:])
  print(2**bits-1)

n, k = list(map(int, input().split()))
cnt = 0
if k == 1:
    print(n)
    return
while(n):
    n //= 2
    cnt += 1
ans = 0
while(cnt):
    ans += 2 ** (cnt - 1)
    cnt -= 1
print(ans)


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

if k==1:
	print(n)
else:
	ans=1
	while ans<=n:
		ans*=2
	ans-=1
	print(ans)


n, k = list(map(int, input().split()))
if k == 1:
    print(n)
else:
    i = 0
    while 2 ** (i + 1) <= n:
        i += 1
    ans = 2 ** (i + 1) - 1
    print(ans)


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

if k == 1:
    print(n)
else:
    print(int(bin(n)[2:].replace('0', '1'), 2))

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

if k == 1:
    ans = n
else:
    ans = 1
    while ans <= n:
        ans *= 2
    ans -= 1
print(ans)


x, y = [int(x) for x in input().split()]  
if y==1:
    print(x)
else:
    nb=x.bit_length()
    print((2**nb)-1)

n,k=[int(x) for x in input().split()]
if k==1:
   print(n)
   return
a=1
s=0
while a<=n:
   s+=a
   a*=2
print(s)