n, m = map(int, input().strip().split(" ")) if n % 2 == 0 and n // 2 <= m: print(2) elif n % 2 != 0 and n <= m: print(1) else: print(-1)