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