Recently there was a single-elimination tournament. The tournament consisted of multiple rounds.
In each round the players were divided into pairs, each pair played a game, and the loser of each game was
eliminated from the tournament. Once there was only a single player left, the tournament terminated and that
player was declared its winner.

If the number of players in a round is odd, it is impossible to divide all of them into pairs. Whenever such
a situation arised, one of the players was awarded a bye and advanced into the next round without playing a game.

Given two integers A and B. You know that the number of players in the tournament was at least A,
and that the total number of byes awarded to players during the tournament was B.

Find and return the smallest possible number of players.

Input Format

The first argument given is integer A.
The second argument given is integer B.

Output Format

Return the smallest possible number of players.


1 <= A <= 2^28
0 <= B <= 28

For Example

Input 1:
    A = 3
    B = 1
Output 1:
Explanation 1:
    A tournament with three people looks as follows:
    1. In the first round one person gets a bye and the remaining two people play a game. Two people advance from this round.
    2. In the second round the two remaining people face off. The loser is out, the winner wins the tournament.
    As the tournament with three people had exactly one bye, this is what we are looking for.

Input 2:
    A = 4
    B = 1
Output 2:
Explanation 2:
    In a tournament with four players there are no byes. 
    In a tournament with five players there are two byes (one in the first round and one in the second). 
    In a tournament with six players there is a single bye (in the second round), hence six is the correct answer for this test case.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Byes on Interview Code Editor
Sign Up
to access hints and editorial solutions for Byes


Click here to start solving coding interview questions