Under construction

Still being built. Things may change

Stay Clear

Time limit8sMemory limit512 MB

Level

Not classified yet

Solved
No attempts yet

Problem

You are at the origin (0,0)(0, 0) of an endless grid. A cell is given by its xx and yy coordinates. Moving one cell to the right increases xx by 1, and moving one cell up increases yy by 1. You want to reach the target cell (x,y)(x, y). In one step you can move to any of the 8 adjacent cells, including the diagonals.

You are eager to start, but first there is a warning. A mysterious figure named Mawarikomiya lurks on this grid. Each time you take a step, he instantly jumps to the cell one step beyond you in the direction you just moved. Precisely, if you move from (xs,ys)(x_s, y_s) to (xt,yt)(x_t, y_t), Mawarikomiya moves to (xt+(xt−xs),yt+(yt−ys))(x_t + (x_t - x_s), y_t + (y_t - y_s)). Stepping into his reach is dangerous. Right after he circles around you, you cannot avoid it. But if Mawarikomiya is already on the cell you plan to move to next, or on any of the 8 cells adjacent to it, you have entered his reach, and you must avoid that.

Using the rules above, what is the minimum number of steps needed to reach the target while staying out of his reach? Write a program that computes this minimum. At the start, Mawarikomiya is on no cell. He appears according to the rule above, beginning after your first step.

In the first sample, the target is (2,0)(2, 0). If you first move to the cell right next to you, (1,0)(1, 0), Mawarikomiya jumps to (2,0)(2, 0), so you cannot step onto it next. If you first move diagonally to (1,1)(1, 1), Mawarikomiya goes to (2,2)(2, 2). Since (2,0)(2, 0) is outside his reach, you can step onto (2,0)(2, 0) on the next move.

Input

Each dataset is one line with two integers xx and yy. This means the target cell is (x,y)(x, y), and ∣x∣,∣y∣≤109|x|, |y| \le 10^9. The input ends at EOF. The total number of datasets does not exceed 50.

Output

For each dataset, print on one line the minimum number of steps needed to move from cell (0,0)(0, 0) to cell (x,y)(x, y) while following the rules above.

Examples1

  1. Example 1

    Input
    2 0
    2 2
    1 -1
    0 0
    0 -5
    173 207
    
    Expected output
    2
    4
    1
    0
    6
    379