n,m=map(int,input().split()) d=-1 if n<=m:d=1 elif (n&1==0) and (n//2)<=m:d=2 print(d)