Gx, Gy = map(int, input().split()) if Gx == 0 or Gy == 0: rook_moves = 1 elif Gx == 0 and Gy == 0: rook_moves = 0 else: rook_moves = 2 if (Gx + Gy) % 2 != 0: bishop_moves = float('inf') else: if Gx == Gy or Gx == -Gy: bishop_moves = 1 elif Gx == 0 or Gx == 0: bishop_moves = 0 else: bishop_moves = 2 print(min(rook_moves, bishop_moves))