Simple Calculator

AtCoder
IDagc008_a
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
Input #1
10 20
Output #1
10

Press button A ten times.
Input #2
10 -10
Output #2
1

Press button B once.
Input #3
\-10 -20
Output #3
12

Press the buttons as follows:

*   Press button B once.
*   Press button A ten times.
*   Press button B once.
API Response (JSON)
{
  "problem": {
    "name": "Simple Calculator",
    "description": {
      "content": "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 ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc008_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Snuke has a calculator. It has a display and two buttons.\nInitially, the display shows an integer $x$. Snuke wants to change this value into another integer $y$, by pressing the following two buttons ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments