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