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