n, m = list(map(int, input().split())) if n % 2 == 1: if n == m: print(1) else: print(-1) else: if n == m: print(1) elif n <= 2 * m: print(2) else: print(-1)