n, m = map(int, input().split()) ans = -1 if m >= n: ans = 1 elif n % 2 == 0 and 2 * m >= n: ans = 2 print(ans)