Gx, Gy = map(int, input().split()) # Tính số bước của Xe if Gx == 0 and Gy == 0: rook_steps = 0 elif Gx == 0 or Gy == 0: rook_steps = 1 else: rook_steps = 2 # Tính số bước của Tượng if Gx == 0 and Gy == 0: bishop_steps = 0 elif abs(Gx) == abs(Gy): bishop_steps = 1 elif (Gx + Gy) % 2 == 0: bishop_steps = 2 else: bishop_steps = float('inf') # Kết quả print(min(rook_steps, bishop_steps))