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