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