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