n,m = [int(i) for i in input().split()] if n==m: print(1) elif m>=n/2 and n%2==0: print(2) else: print(-1)