#B4097. Minimum Moves on a Number Line

    ID: 11754 Type: Default 1000ms 256MiB

Minimum Moves on a Number Line

Minimum Moves on a Number Line

Consider an infinite one‐dimensional board whose cells are indexed by all integers. The cell at index \(0\) is at the center, cells to the right are labeled \(1, 2, 3, \dots\) and to the left are labeled \(-1, -2, -3, \dots\). You are given two integers \(x\) and \(y\), representing the starting and target positions, respectively.

You can perform two kinds of operations:

  • Operation 1: Move one step to the right, i.e. from a cell \(a\) go to \(a+1\).
  • Operation 2: Jump from the current cell \(a\) to cell \(-a\) (i.e. apply the transformation \(a\to -a\) in one move).

It can be proved that for any integers \(x\) and \(y\) the target can always be reached. Your task is to compute the minimum number of operations required to move the piece from cell \(x\) to cell \(y\).

Note: When using formulas, express them in LaTeX format (for instance, \(a \to -a\)).

inputFormat

The input consists of a single line with two space‐separated integers \(x\) and \(y\), where \(-10^9 \le x,y \le 10^9\).

outputFormat

Output a single integer representing the minimum number of operations required to move from cell \(x\) to cell \(y\).

sample

-3 5
3