Time Limit:10000ms Memory Limit:65536KB

Description

The are N (N=2^i, i>=0) players attending a competition.
In the first round, they compete in pairs, and half of them advance into the second round.
In the second round, they compete in pairs, and half of them advance into the third round.
...
The last one is the finnal winner.
Each player has his rank(from 1 to N, the smaller the better).
Player 1's rank is 1, player 2's rank is 2, and so on.
If the difference rank of two players is larger than K, the small-rank one can always beat the other.
Given N(1<=N<=65536)and K(0<=K<=N), who can be the finnal winner with the largest rank?

Input

Mutiple test cases.
Each line is two integers N and K seperated by a space

Output

For each test case, output the largest rank in a single line.

Sample Input

8 0
8 2
8 8

Sample Output

1
6
8

Hint

round1: 6->7 5->3 4->8 2->1
round2: 6->5 4->2
round3: 6->4
A->B means A beat B.
It's possible than 4->6 in the third round, but we should only consider the best
case for the reason of maximizing the winner's rank.
In another word, we can control the result between any two players, except when
their rank difference is larger than K.

Author

baihacker

Source