Alice and Bob have an integer $N$. Alice and Bob are not happy with their integer. Last night they went to a cocktail party and found that another couple had the exact same integer! Because of that they are getting a new integer.
Bob wants to impress the other couple and therefore he thinks their new integer should be strictly larger than $N$.
Alice herself is actually fond of some specific integer $k$. Therefore, Alice thinks that whatever integer they pick, it should be possible to write it as a sum of $k$ distinct powers of $2$.
Bob is also a cheapskate, therefore he wants to spend as little money as possible. Since the cost of an integer is proportional to its size, he wants to get an integer that is as small as possible.
A single line containing two integers $N$ and $k$, with $1 \leq N \leq 10^{18}$ and $1 \leq k \leq 60$.
Output $M$, the smallest integer larger than $N$ that can be written as the sum of exactly $k$ distinct powers of $2$.
Sample Input 1 | Sample Output 1 |
---|---|
1 2 |
3 |
Sample Input 2 | Sample Output 2 |
---|---|
12 2 |
17 |
Sample Input 3 | Sample Output 3 |
---|---|
1 5 |
31 |
Sample Input 4 | Sample Output 4 |
---|---|
182 3 |
193 |