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