A - Simple Calculator Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 300

問題文

すぬけ君は電卓を持っています。 この電卓にはディスプレイと 2 個のボタンが付いています。

最初、ディスプレイの値は整数 x です。 すぬけ君の目標は、ディスプレイの値を整数 y にすることです。 そのために、すぬけ君は次の 2 個のボタンを好きな順番で何回か押すことができます。

  • ボタン A : ディスプレイの値を 1 増やす。
  • ボタン B : ディスプレイの値の符号を反転する。

目標を達成するためにすぬけ君がボタンを押す回数の最小値を求めてください。 なお、整数 x, y の値によらず、必ず目標を達成できることが示せます。

制約

  • x, y は整数である。
  • |x|, |y| ≤ 10^9
  • x, y は相異なる。

入力

入力は以下の形式で標準入力から与えられる。

x y

出力

目標を達成するためにすぬけ君がボタンを押す回数の最小値を出力せよ。


入力例 1

10 20

出力例 1

10

ボタン A を 10 回押せばよいです。


入力例 2

10 -10

出力例 2

1

ボタン B を 1 回押せばよいです。


入力例 3

-10 -20

出力例 3

12

次の順でボタンを押せばよいです。

  • ボタン B を 1 回押す。
  • ボタン A を 10 回押す。
  • ボタン B を 1 回押す。

Score : 300 points

Problem Statement

Snuke has a calculator. It has a display and two buttons.

Initially, the display shows an integer x. Snuke wants to change this value into another integer y, by pressing the following two buttons some number of times in arbitrary order:

  • Button A: When pressed, the value on the display is incremented by 1.
  • Button B: When pressed, the sign of the value on the display is reversed.

Find the minimum number of times Snuke needs to press the buttons to achieve his objective. It can be shown that the objective is always achievable regardless of the values of the integers x and y.

Constraints

  • x and y are integers.
  • |x|, |y| ≤ 10^9
  • x and y are different.

Input

The input is given from Standard Input in the following format:

x y

Output

Print the minimum number of times Snuke needs to press the buttons to achieve his objective.


Sample Input 1

10 20

Sample Output 1

10

Press button A ten times.


Sample Input 2

10 -10

Sample Output 2

1

Press button B once.


Sample Input 3

-10 -20

Sample Output 3

12

Press the buttons as follows:

  • Press button B once.
  • Press button A ten times.
  • Press button B once.