n, m = map(int, input().split())

def f(n, m):
  if m >= n:
    return 1
  elif n % 2 == 0:
    if m >= n // 2:
      return 2
    elif m >= n // 2 + 1:
      return 2
  else:
    return -1

print(f(n, m))