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