A haunted pumpkin has landed in Alice's backyard, just in time for Halloween! It has the spooky property of spreading: Every night, the amount of pumpkins in Alice's backyard will double, until she casts a spell to end the process. Alice doesn't want to disenchant the pumpkin yet, she would like to have exactly $$$n$$$ pumpkins in her backyard first. She can also do some work in her yard to remove pumpkins, removing up to $$$k$$$ pumpkins every day.
Thus, every day, Alice may choose to do one of the following:
Find the minimum amount of days for Alice to reach her goal of her garden ending up with $$$n$$$ pumpkins! Note that she must always cast the spell to stop the doubling exactly once.
The integers $$$n$$$ ($$$1 \leq n \leq 1000$$$) and $$$k$$$ $$$(1 \leq k \leq 1000)$$$, the number of pumpkins Alice wants, and the amount she can remove every day. There is initially 1 pumpkin.
Output a single integer, the minimum number of days for Alice to reach $$$n$$$ pumpkins.
7 1
5
10 2
5
1 1000
1
In the first case, the optimal answer is 5. Alice should let the pumpkins double for 3 days, getting to 8 pumpkins. On day 4, she should cast the spell to stop the doubling, remaining at 8 pumpkins. On day 5, she should remove 1 pumpkin.
In the second case, the optimal answer is 5. Alice should let the pumpkins double for 2 days, getting to 4 pumpkins. On day 3, she should remove a pumpkin, going down to 3, which then doubles to 6. On day 4, she should remove a pumpkin, going down to 5, which then doubles to 10. On day 5, she should cast the spell to stop the doubling.
In the third case, the optimal answer is 1. Alice has 1 pumpkin, and should cast the spell to stop the doubling.