n, m = map(int, input().split()) if n % 2: if m >= n: print(1) else: print(-1) else: if m >= n: print(1) elif m * 2 >= n: print(2) else: print(-1)