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