Counting Game

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 2656
64-bit integer IO format: %I64d      Java class name: Main

Description

Let's define the number of '1' of X in base 2 is V(X).Now give you an X and a k, please give me the kth number Y strictly greater than X and V(X) = V(Y).

Input

Input includes several cases. Each case contains one line with two integers X, k. Input ends with a case X = 0 and k = 0. X is a 32-bit integer, 0 < K <= 50000.

Output

Every case print a integer Y in a line. Y is guaranteed to be a 32-bit integer.

Sample Input

5 1
481 2
0 0

Sample Output

6
484

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .