n,m = map(int,input().split()) ans = -1 if n <= m: ans = 1 else: if not n % 2 and n // 2 <= m: ans = 2 print(ans)