n,m = map(int,input().split()) if n == 2 or n <= m: print(1) elif (~n&1) and n <= m*2: print(2) else: print(-1)