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