N, M = map(int, input().split()) if N < M + 1: print(1) elif N % 2 == 0 and N // 2 < M + 1: print(2) else: print(-1)