Crocodile Hunting – 2
As you possibly remember the main occupation of unhappy savages from Bad Luck Island is crocodile hunting. This time they have decided to use a trap which is located in the center of the lake in the point with coordinates (0, 0). But the boats on Bad Luck Island move according to a very strange law. From the point with coordinates (X_k, Y_k) the boat can move only to the point with coordinates X_{k+1} = X_k + Y_k Y_{k+1} = Y_k + U_k where U_k is a force which is used by savages for acceleration or braking the boat. The boat can be located only in the point with integer coordinates (X_k, Y_k are integers for any k >= 0). U_k takes the values from the set {-2, -1, 0, 1, 2} for any k >= 0. Naturally, savages would like to reach the trap as fast as possible while crocodile does not free himself. Your task is to find the minimal possible value T for which X_T = 0, Y_T = 0 for given initial location of the boat (X_0, Y_0).
The input text file input.txt contains several test cases. Each test case is a line with two integers separated by one space – initial location of the boat (X_0, Y_0), (-100 <= X0 <= 100, -100 <= Y_0 <= 100). It is guaranteed that the point (0, 0) can be reached from any initial location given in the input file. The input is terminated by EOF. For each initial location (X_0, Y_0) from the input file output into separate line of standard output the only number – the minimal possible value T for which X_T = 0, Y_T = 0.