#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  --n;
  --k;
  if (n > (k * (k + 1) / 2)) {
    cout << -1 << endl;
    return 0;
  }
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  long long m = k * (k + 1) / 2;
  m = m + 1;
  long long val = m - n;
  long long left = 1, right = k, ans = -1;
  while (left <= right) {
    long long mid = (left + right) / 2;
    if (mid * (mid + 1) >= (2 * val)) {
      ans = mid;
      right = mid - 1;
    } else
      left = mid + 1;
  }
  if (ans != -1)
    ans = k + 1 - ans;
  else
    ans = 1;
  cout << ans << endl;
  return 0;
}
