#include <bits/stdc++.h>
int main(void) {
  long long int n, k;
  scanf("%lld %lld", &n, &k);
  long long ans = -1, res;
  long long lo = 2, hi = k;
  while (lo <= hi) {
    long long mid = (lo + hi) / 2;
    long long left = mid * (mid + 1) / 2 - 1, right = k * (k + 1) / 2 - 1;
    long long ret = (right - left) - (k - mid - 1);
    if (ret <= n) {
      ans = mid;
      res = ret;
      hi = mid - 1;
    } else
      lo = mid + 1;
  }
  if (ans != -1) {
    long long rem = n - res;
    if (rem) rem++;
    if (!rem || (rem <= ans && rem > 1)) {
      long long needed = k - ans;
      if (rem) needed++;
      printf("%lld\n", needed);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
