x, y = map(int, input().split()) dist = {} que = [(0, x, y)] for n, x, y in que: if -100<=x<=100 and -100<=y<=100 and (x, y) not in dist: if x == y: print(n) break dist[x, y] = n que += [(n+1, x+y, x-y), (n+1, y, x)] else: print(-1)