P26510 [AtCoder] Iberutaru
NOI
题目描述

Problem Description

Iberutaru is a Pokémon with a Y-shaped form.

Iberutaru is located at coordinates \( (0,0) \) on a 2D grid and is trying to return to its nest at coordinates \( (X,Y) \).

Iberutaru can move in three directions: up, right, and down-left, taking 1 second for each move. That is, from coordinates \( (x,y) \), it can move to coordinates \( (x,y+1) \), \( (x+1,y) \), or \( (x-1,y-1) \) in 1 second. Additionally, Iberutaru cannot move consecutively in the same direction more than twice.

What is the minimum number of seconds required for Iberutaru to return to its nest?

Input Format

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

\( X \) \( Y \)

Output Format

Output the minimum number of seconds required for Iberutaru to return to its nest.

Sample Input and Output

Sample Input #1

2 0

Sample Output #1

5

Sample Input #2

-2 -3

Sample Output #2

7

Sample Input #3

-1000000000 1000000000

Sample Output #3

5999999997

Sample Input #4

0 0

Sample Output #4

0

Notes/Hints

Constraints

  • \( -10^9 \leq X,Y \leq 10^9 \)

Sample Explanation 1

The shortest path is as shown in the figure, taking 5 seconds. Note that moving consecutively in the same direction more than twice is not allowed. 3d2a3ec64196bd9b8c5ddbe8adfc8264.png

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 0
样例输出
5