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