#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, total, nb = 0;
  cin >> n >> k;
  total = 1;
  bool ok = true;
  if (1 + k * (k - 1) / 2 < n) {
    ok = false;
  } else {
    while (total < n) {
      total += k - 1;
      --k;
      ++nb;
    }
  }
  if (ok == true)
    cout << nb << endl;
  else
    cout << "-1" << endl;
  return 0;
}
