Grid Forest

On the integer lattice, one unit step moves between adjacent trees; find the shortest walk from (x, y) to the origin that keeps the origin visible at every stop.

Medium5MathNumber theoryBFSGraphNo attempts yetTime limit1sMemory limit32 MB

Problem

Yonghun is lost in a grid forest. One tree stands at every integer point of the coordinate plane, and his home sits at the origin (0,0)(0, 0) in place of a tree. He spotted the home far away and worked out where he is: he stands at the tree (x,y)(x, y), which is xx to the east and yy to the north of the home.

Yonghun picks one of the four directions east, west, south, north, and once he starts moving he does not stop until he reaches the next tree or the home. One move takes him from the tree (a,b)(a, b) to one of (a+1,b)(a+1, b), (a1,b)(a-1, b), (a,b+1)(a, b+1), (a,b1)(a, b-1) and costs 11 unit of time. He may also step onto points with negative coordinates.

To keep his sense of direction, the home must be visible from every tree he stops at. Trees and the home are so small that they count as points. The home is visible from the tree (a,b)(a, b) when no other tree lies on the segment joining (a,b)(a, b) and (0,0)(0, 0), endpoints excluded.

Given the starting coordinates, write a program that finds the shortest time Yonghun needs to reach the home.

Input

The first line contains the xx coordinate and the yy coordinate of Yonghun, separated by a space. (0x,y1080 \le x, y \le 108)

The home is guaranteed to be visible from his starting position. If (x,y)=(0,0)(x, y) = (0, 0), he is already home.

Output

Print the shortest time Yonghun needs to reach the home on the first line. Print 1-1 if he cannot reach it.