#yuki_531 n,m=map(int,raw_input().split()) if m>=n: print 1 elif n%2==0 and n/2<=m: print 2 else: print -1