P25348 [AtCoder] Safe
普及
题目描述

Problem Description

You have a stuffed animal that you cherish and keep in a safe with a lock. The safe has a dial with markings from $-100$ to $100$ in integer values. Initially, the dial is set to $0$.

The safe can be opened by first setting the dial to $A$, then to $B$, and finally back to $0$. You can set the dial to $B$ before setting it to $A$, but you must still set it to $A$ and then back to $B$ again.

The dial can only be moved one unit at a time. However, it cannot be moved below $-100$ or above $100$.

Each time the dial is moved, a sound is produced. For example, if the dial is moved from $0$ to $5$ incrementally, the sound will be produced $5$ times.

You dislike the sound the safe makes and want to know the minimum number of times the sound can be produced.

Input Format

The input is provided from the standard input in the following format:

$ A $ $ B $

  • The first line contains the integer $A$ ($-100 \leq A \leq 100$).
  • The second line contains the integer $B$ ($-100 \leq B \leq 100$).
  • $A \neq 0$, $B \neq 0$, and $A \neq B$.

Output Format

Output the minimum number of times the sound can be produced on one line. Ensure a newline at the end of the output.

Sample Input and Output

Sample Input #1

5
-2

Sample Output #1

14

Sample Input #2

4
3

Sample Output #2

8

Sample Input #3

-40
-91

Sample Output #3

182

Notes/Hints

Sample Explanation 1

By moving the dial from $0$ to $5$, then back to $0$, and finally to $-2$ and back to $0$, the sound can be produced 14 times.

Sample Explanation 2

It is possible for the dial to match the value specified by $B$ first.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 -2
样例输出
14