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