Loo Rolls

Time limit1sMemory limit512 MB

Summary
Find the smallest number of loo rolls, each of length l, so that consuming n per visit never triggers a shortage.
Level

Hard8 of 10

Topics
Math, Number theory, Dynamic programming, Binary search
Solved
No attempts yet

Problem

Your friend Nick needs help with a hard problem he came across in real life. Nick has a loo roll of length ℓ centimetres in his bathroom. Every time he visits the toilet, he uses exactly n centimetres of loo roll. When the roll runs out, Nick always goes to the store and buys a new one of length ℓ right afterwards. Sometimes, though, the roll runs out while Nick still needs a non-zero amount of paper. Call such an event a crisis.

Nick has a clever way to prevent crises: he uses a backup roll. The backup roll is another roll of length ℓ hidden somewhere in the bathroom. When the regular roll runs out while Nick still needs more paper, he takes that amount from the backup roll. Then he replaces the regular roll right after the visit.

As you can imagine, this makes crises much less frequent. The backup roll also slowly runs out, though, and eventually a crisis might still happen. To generalize this, Nick wants several layers of backup rolls. First he takes paper from roll number 1 (the regular roll); if it runs out he takes from roll number 2, then if roll 2 runs out from roll number 3, and so on up to roll number k. After each visit, all the rolls that have run out are replaced. Nick proved that with a large enough k he can actually make crises never happen. Your task is to find the smallest such k.

Input

The input consists of a single line containing the two integers ℓ and n (1 ≤ n ≤ ℓ ≤ 1010).

Output

Output the smallest integer k such that crises will never happen when using k layers of rolls (including the regular roll).

Examples2

  1. Example 1

    Input
    31 6
    
    Expected output
    4
    
  2. Example 2

    Input
    10000000000 17
    
    Expected output
    3