#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  if (n > (k * (k - 1)) / 2 + 1) {
    cout << -1 << endl;
    return 0;
  }
  long long int lo = 0, hi = k - 1, total = k * (k - 1) / 2;
  n--;
  while (lo < hi) {
    long long int mid = (lo + hi + 1) / 2;
    long long int pre = mid * (mid + 1) / 2;
    if (total - pre < n) {
      hi = mid - 1;
    } else {
      lo = mid;
    }
  }
  cout << k - lo - 1;
}
