#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j, k, p, q, r, l;
  cin >> n >> k;
  k--;
  p = (k * (k + 1)) / 2;
  l = 0;
  r = k;
  long long int mid, ans1 = -1;
  while (l <= r) {
    mid = (l + r) / 2;
    q = p - (mid * (mid + 1)) / 2;
    if ((q + 1) >= n) {
      ans1 = (k - mid);
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << ans1;
  return 0;
}
