import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # 複素平面で z -> i conjugate(z) or 1+i conjugate(z) X,Y = map(int,read().split()) Z = complex(X,Y) se = set([Z]) answer = -1 for i in range(10): if any(z.real == z.imag for z in se): answer = i break se = set(1j * z.conjugate() for z in se) | \ set((1+1j) * z.conjugate() for z in se) print(answer)