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) in place of a tree. He spotted the home far away and worked out where he is: he stands at the tree (x,y), which is x to the east and y 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) to one of (a+1,b), (a−1,b), (a,b+1), (a,b−1) and costs 1 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) when no other tree lies on the segment joining (a,b) and (0,0), endpoints excluded.
Given the starting coordinates, write a program that finds the shortest time Yonghun needs to reach the home.