Gx, Gy = map(int, input().split()) if Gx == 0 and Gy == 0: print(0) else: # Check Luke's moves luke_moves = 0 if Gx == 0 or Gy == 0: luke_moves = 1 else: luke_moves = 2 # Check Bishop's moves bishop_moves = 0 if (Gx + Gy) % 2 != 0: bishop_moves = float('inf') else: if abs(Gx) == abs(Gy): bishop_moves = 1 else: bishop_moves = 2 min_moves = min(luke_moves, bishop_moves) print(min_moves)