n, m = map(int,input().split()) res = None if m >= n: res = 1 else: if n % 2 == 0: reduce = m if reduce == 1: res = -1 else: if reduce % 2 == 1: reduce -= 1 rest = n // 2 count = 1 while rest > 0: rest -= reduce count += 1 res = count else: res = -1 print(res)