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