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