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