#include <bits/stdc++.h>
using namespace std;
void rip(long long x) {
  cout << x << endl;
  exit(0);
}
int main() {
  long long n, k;
  cin >> n >> k;
  k--;
  if (n == 1) rip(0);
  if (k >= n) rip(1);
  if ((k * (k + 1)) / 2 + 1 < n) rip(-1);
  long long s = 1, e = k, m, a, lt = 1;
  while (s <= e) {
    m = s + (e - s) / 2;
    long long amt = (m * (m + 1)) / 2 + (k - m) * m;
    if (amt <= n - 1) {
      a = m;
      if (amt == n - 1) lt = 0;
      s = m + 1;
    } else {
      e = m - 1;
    }
  }
  if (a != -1) {
    cout << a + lt << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
