ss = input().split() n = int(ss[0]) m = int(ss[1]) if n <= m: print(1) elif m >= n / 2 and n % 2 == 0: print(2) else: print(-1)