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