#Nskmi n,m=(int(i) for i in input().split()) if m>=n: p=1 elif n%2==1: p=-1 else: n//=2 if n<=m: p=2 print(p)