#include <bits/stdc++.h>
using namespace std;
long long sum(long long n) { return (n * (n + 1)) / 2; }
long long sum(long long s, long long e) {
  if (s <= 1) return sum(e);
  return sum(e) - sum(s - 1);
}
long long minSplitters(long long k, long long n) {
  long long st = 1, en = k;
  while (st < en) {
    long long md = (st + en) / 2;
    long long s = sum(md, k);
    if (s == n) return k - md + 1;
    if (s > n)
      st = md + 1;
    else
      en = md;
  }
  return k - st + 2;
}
int main() {
  long long n, k;
  cin >> n >> k;
  if (n == 1)
    cout << 0 << "\n";
  else if (n <= k)
    cout << 1 << "\n";
  else {
    --k;
    --n;
    if (sum(k) < n)
      cout << -1 << "\n";
    else
      cout << minSplitters(k, n) << "\n";
  }
  return 0;
}
