# coding: utf-8 import sys def solve(): # 標準入力から Gx と Gy を受け取る # Read Gx and Gy from standard input gx, gy = map(int, sys.stdin.readline().split()) # Case 0: ゴールが原点の場合 # Case 0: If the goal is the origin if gx == 0 and gy == 0: print(0) return # Case 1: 1手で到達可能な場合 # Case 1: If reachable in 1 move # ルークで1手 (x軸またはy軸上) # Rook in 1 move (on x-axis or y-axis) is_rook_1_move = (gx == 0 or gy == 0) # ビショップで1手 (y=x または y=-x 上) # Bishop in 1 move (on y=x or y=-x) is_bishop_1_move = (gx == gy or gx == -gy) if is_rook_1_move or is_bishop_1_move: print(1) return # Case 2: 2手で到達可能な場合 # Case 2: If reachable in 2 moves # 上記の1手の条件を満たさない場合、ルークでは必ず2手で到達可能。 # If the 1-move conditions above are not met, the rook can always reach in 2 moves. # ビショップで到達可能か (座標の偶奇が一致するか) を確認する。 # Check if the bishop can reach (if the parity of coordinates matches). # (gx + gy) % 2 == 0 は、gx と gy の偶奇が一致することと同値。 # (gx + gy) % 2 == 0 is equivalent to gx and gy having the same parity. is_bishop_reachable = ((gx + gy) % 2 == 0) # 1手で到達できず、ビショップで到達可能なら、ルークもビショップも2手。最小2手。 # If not reachable in 1 move and bishop can reach, both rook and bishop take 2 moves. Minimum is 2. # 1手で到達できず、ビショップで到達不可能でも、ルークが2手で到達できるので最小2手。 # If not reachable in 1 move and bishop cannot reach, the rook can still reach in 2 moves. Minimum is 2. print(2) # 関数を実行 # Execute the function solve()