#include <bits/stdc++.h>
using namespace std;
long long k, n;
int main() {
  cin >> n >> k;
  if (k >= n) {
    if (n == 1) {
      cout << 0;
      return 0;
    }
    cout << 1;
    return 0;
  }
  long long sum = 1;
  int cc = 0;
  for (int i = k; i > 1; i--) {
    sum = sum - 1 + i;
    cc++;
    if (sum >= n) {
      cout << cc;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
