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