N, M = map(int, input().split()) print(1 if M >= N else [-1, 2][N % 2 == 0 and M >= N / 2])