#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, n, in, en, mid, ts, sum;
  while (cin >> n) {
    cin >> k;
    n--;
    k--;
    if ((k * (k + 1)) / 2 < n) {
      cout << "-1\n";
      continue;
    }
    in = 0;
    en = k;
    ts = (k * (k + 1)) / 2;
    while (in <= en) {
      mid = (in + en) / 2;
      sum = ts - ((mid * (mid + 1)) / 2);
      if (sum <= n && sum + mid > n) break;
      if (sum + mid <= n) en = mid - 1;
      if (sum > n) in = mid + 1;
    }
    if (sum < n)
      cout << (k - mid + 1) << "\n";
    else
      cout << (k - mid) << "\n";
  }
  return 0;
}
