eolymp
bolt
Try our new interface for solving problems
Problems

Crocodile Hunting – 2

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 (\textbf{0}, \textbf{0}). But the boats on Bad Luck Island move according to a very strange law. From the point with coordinates (\textbf{X_k}, \textbf{Y_k}) the boat can move only to the point with coordinates \textbf{X_\{k+1\}} = \textbf{X_k} + \textbf{Y_k} \textbf{Y_\{k+1\}} = \textbf{Y_k} + \textbf{U_k} where \textbf{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 (\textbf{X_k}, \textbf{Y_k} are integers for any \textbf{k} >= \textbf{0}). \textbf{U_k} takes the values from the set \{\textbf{-2}, \textbf{-1}, \textbf{0}, \textbf{1}, \textbf{2}\} for any \textbf{k} >= \textbf{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 \textbf{T} for which \textbf{X_T} = \textbf{0}, \textbf{Y_T} = \textbf{0} for given initial location of the boat (\textbf{X_0}, \textbf{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 (\textbf{X_0}, \textbf{Y_0}), (\textbf{-100} <= \textbf{X0} <= \textbf{100}, \textbf{-100} <= \textbf{Y_0} <= \textbf{100}). It is guaranteed that the point (\textbf{0}, \textbf{0}) can be reached from any initial location given in the input file. The input is terminated by EOF. For each initial location (\textbf{X_0}, \textbf{Y_0}) from the input file output into separate line of standard output the only number -- the minimal possible value \textbf{T} for which \textbf{X_T} = \textbf{0}, \textbf{Y_T} = \textbf{0}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1 1
2 0
-1 -1
Output example #1
3
2
3