Gx, Gy = map(int, input().split()) # Rook moves if Gx == 0 or Gy == 0: rook = 1 else: rook = 2 # Bishop moves if (Gx + Gy) % 2 != 0: bishop = float('inf') # Unreachable elif Gx == Gy or Gx == -Gy: bishop = 1 else: bishop = 2 print(min(rook, bishop))