#include <bits/stdc++.h>
long long K, MAX;
inline long long sum(long long k) {
  k = K - k;
  return MAX - (k + 1) * k / 2;
}
int Work() {
  long long n, k;
  scanf("%I64d%I64d", &n, &K);
  n--;
  K--;
  MAX = (K + 1) * K / 2;
  if (sum(K) < n) {
    printf("-1\n");
    return 0;
  } else {
    long long l = 0, r = K;
    long long mid;
    while (l < r) {
      mid = (l + r) >> 1;
      if (sum(mid) < n)
        l = mid + 1;
      else
        r = mid;
    }
    printf("%I64d\n", l);
  }
  return 0;
}
int main() {
  Work();
  return 0;
}
