431_D. Random Task
One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m numbers which binary representation contains exactly k digits one".

The girl got interested in the task and she asked you to help her solve it. Sasha knows that you are afraid of large numbers, so she guaranteed that there is an answer that doesn't exceed 1018.

Input

The first line contains two space-separated integers, m and k (0 ≤ m ≤ 1018; 1 ≤ k ≤ 64).

Output

Print the required number n (1 ≤ n ≤ 1018). If there are multiple answers, print any of them.

Examples

Input

1 1


Output

1


Input

3 2


Output

5
```python
def dfs(n, k, cache = {}):
    # if number of bits is bigger than the number's bits of the number's bits is less than 0
    if k > n or k < 0: return 0
    # if num bits is 0 or num bits is equivalent to the number's bits
    if k == 0 or k == n: return 1
    # This optimization is not necessary but flips the 0s and the 1s
    # if k*2 > n: k = n-k
    # Check is already calculated
    if (n, k) in cache: return cache[(n, k)]
    # Use dfs addition for case where certain bit is 1 or certain bit is 0
    z = cache[(n, k)] = dfs(n-1, k-1) + dfs(n-1, k)
    return z

def bits(n):
    # counts number of 1s in the number
    b = 0
    while n:
        if n & 1: b += 1
        n >>= 1
    return b

def count(n, k):
    z, b, c = 0, 63, 0
    for b in reversed(range(64)):
        # Taking n and checking if certain bit is 1 or not
        # This sums for every mod power of 2 that exists to account for every case
        if (n>>b)&1:
            # calculates by subtracting for bits not accounted for
            z += dfs(b, k-c)
            c += 1
        # Unnecessary code
        # if not k: break
    # if original number has same number of 1s as digits required, add 1
    return z + (bits(n) == k)

def solve(m, k):
    # Binary Search for number 1-10^18
    low, high = 1, 10**18
    while low < high:
        mid = (low+high)//2
        if count(2*mid, k) - count(mid, k) < m:
            low = mid+1
        else:
            high = mid
    return high

m, k = [int(x) for x in input().split()]
print(solve(m, k))
```