#include <bits/stdc++.h>
using namespace std;
long long n, k;
inline long long sum(long long m) { return m * (m + 1) / 2; }
inline long long sum(long long s, long long e) {
  if (s <= 1) return sum(e);
  return sum(e) - sum(s - 1);
}
long long BS() {
  long long lo = 1, hi = k;
  while (hi > lo) {
    long long mid = (lo + hi) >> 1;
    long long s = sum(mid, k);
    if (s == n)
      return k - mid + 1;
    else if (s > n) {
      lo = mid + 1;
    } else
      hi = mid;
  }
  return k - lo + 2;
}
int main() {
  scanf("%I64d %I64d", &n, &k);
  if (n == 1)
    cout << 0 << endl;
  else if (n <= k)
    cout << 1 << endl;
  else {
    n--, k--;
    if (sum(k) < n) return 0 * puts("-1");
    cout << BS() << endl;
  }
  return 0;
}
