Anticlockwise Motion

Given two cells of an anticlockwise spiral numbered from the center, find the Manhattan distance between them.

Medium4MathImplementationNo attempts yetTime limit1sMemory limit512 MB

Problem

You have an idea for a board game. The board is a grid of 32001×3200132001 \times 32001 numbered squares. The centre square holds the number 1, and every other number sits on an anticlockwise spiral that grows outwards. The spiral first moves downwards, then to the right, then upwards, then to the left, then downwards again, and so on. The figure below shows the middle 25 squares, and the figure in the hint shows the middle 441 squares.

Figure A.1: the middle 25 squares.

A player moves one square at a time, up, down, left, or right. Given the numbers of two squares, find the smallest number of moves needed to get from one to the other.

Input

The first and only line contains the number aa of the starting square and the number bb of the ending square, separated by a space. (1a1091 \le a \le 10^9, 1b1091 \le b \le 10^9)

Output

Print the shortest distance between square aa and square bb, that is the minimum number of moves.

Hint

Figure A.2: the middle 441 squares.