Under construction

Still being built. Things may change

Bookshelf

Time limit2sMemory limit1024 MB

Summary
Given book height h and span r, find the fewest extra books needed so that toppling the leftmost book knocks over the rightmost one.
Level

Medium4 of 10

Topics
Math, Geometry
Solved
No attempts yet

Statement

Doctor Strange keeps a large library in his mansion. Today he is thinking about the domino effect, and books help with that even if nobody reads them.

The Sorcerer Supreme has an infinite number of ultra-thin books of height hh. The bookshelf can be viewed as a number line, and books can only be placed at integer coordinates. Wong has already placed books at coordinates 00 and rr.

A book at coordinate aa knocks over a book at coordinate bb when it falls, if at the moment the top point of the first book is at coordinate bb and height yy, then y≥h2y \ge \frac{h}{2}. The thickness of a book is negligible.

Strange had to work through 14 000 60514\,000\,605 possible futures to find the minimum number of books that must be placed between the two original ones, so that pushing the book at coordinate 00 can eventually topple the book at coordinate rr. Wong does not know this kind of magic, so he asks you to solve this puzzle.

Input

The first line contains one even positive integer hh, the height of the books (2≤h≤1062 \le h \le 10^6).

The second line contains one positive integer rr, the coordinate of the rightmost book (1≤r≤1061 \le r \le 10^6).

Output

Print one number: the minimum number of books that must be placed so that pushing the leftmost book can topple the rightmost book.

Examples2

  1. Example 1

    Input
    2
    5
    
    Expected output
    4
    
  2. Example 2

    Input
    4
    2
    
    Expected output
    0