#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

Why did the chicken cross the road? To get to the other side!

Why did a group of bears and penguins cross the river? To get to the other bank!

Well actually, a group of *N* bears and *N* penguins are crossing the river because they are going to take part in the Numinous Order of Immortals (NOI), located at the other side of the river. However, there is a problem. There is only one boat that can be used to fetch the bears and penguins across the river (You see, these bears and penguins can't swim, although all of them know how to row a boat). This boat can only hold up to *K* bears and penguins at any time, and must be manned by at least one bear or penguin at any time.

The bears and penguins decide to take turns to ride the boat until all of them get across. However, there is a problem. The bears are big bullies and like to torture penguins. Bullied penguins get very sad. To prevent penguins from getting sad (because penguins are holy animals that should always remain happy), the penguins cannot be outnumbered any time throughout the whole trip. This means that if there are penguins on one side of the bank, the number of penguins on that side of the bank must strictly be more than or equal to the number of bears on that side of the bank at all times.

The bears and penguins don't have all day. Therefore, they want to know what is the minimum number of trips they need to take to get everyone across safe and happy. Can you help them out?

## Input

The first and only line contains two space-separated integers,*N*and

*K*.

## Output

Output on a single line the minimum number of trips required to get everyone across. If there is no possible solution, output "-1".## Constraints

For 10% of test data, 1 ≤ *N* ≤ 10.

For 30% of test data, 1 ≤ *N* ≤ 500.

For 50% of test data, 1 ≤ *N* ≤ 1,000.

For 80% of test data, 1 ≤ *N* ≤ 100,000.

For 90% of test data, 1 ≤ *N* ≤ 10^{9}.

For 100% of test data, 1 ≤ *N* ≤ 10^{17} and 1 ≤ *K* ≤ 10^{18}.

## Sample Input 1

2 2

## Sample Output 1

5

## Explanation for Sample Output 1

Here is one possible solution.

Trip 1: Bring 1 penguin and 1 bear across.

Trip 2: Bring 1 penguin back.

Trip 3: Bring 2 penguins across.

Trip 4: Bring 1 bear back.

Trip 5: Bring 2 bears across.

After this, everyone has crossed the river safe and happy.

## Sample Input 2

3 2

## Sample Output 2

11

## Explanation for Sample Output 2

The above sample input is a well-known puzzle given to children.

Barring some errors, here are the moves:

Trip 1: Bring 2 bears over.

Trip 2: Bring 1 bear back.

Trip 3: Bring 2 bears over.

Trip 4: Bring 1 bear back.

Trip 5: Bring 2 penguins over.

Trip 6: Bring 1 penguin and 1 bear back.

Trip 7: Bring 2 penguins over.

Trip 8: Bring 1 bear back.

Trip 9: Bring 2 bears over.

Trip 10: Bring 1 bear back.

Trip 11: Bring 2 bears over.

After this, everyone has crossed the river safe and happy.

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 100 | 30 | 1s | 32MB | Average |

2 | 0 | 2 | 1s | 32MB | Average |

### Judge Compile Command

g++-7 ans.cpp -o river -Wall -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512