#include <bits/stdc++.h>
using namespace std;
long long search(long long k, long long n) {
  long long low = 1, high = k - 1;
  while (high - low >= 4) {
    long long mid = low + (high - low) / 2;
    long long temp =
        ((k * (k + 1)) / 2) - ((mid * (mid + 1)) / 2) - (k - mid - 1);
    if (temp >= n)
      low = mid;
    else
      high = mid + 1;
  }
  for (long long i = high; i >= low; i--) {
    if (i == k && i >= n) return k - 1;
    long long temp = ((k * (k + 1)) / 2) - ((i * (i + 1)) / 2) - (k - i - 1);
    if (temp >= n) return i;
  }
}
int main() {
  long long i, j, k = 0, n, max;
  cin >> n >> k;
  max = ((k * (k + 1)) / 2) - (k - 1);
  if (n == 1) {
    cout << "0";
    return 0;
  }
  if (n > max)
    cout << "-1";
  else {
    cout << k - search(k, n);
  }
  return 0;
}
