#include <bits/stdc++.h>
using namespace std;
int const N = 1e5 + 5;
int di[] = {1, 1, -1, -1};
int dj[] = {1, -1, 1, -1};
long long n, k;
long long solv() {
  long long st = 0, ed = k, ans;
  while (st <= ed) {
    long long x = (k * (k + 1)) / 2;
    long long mid = (st + ed) / 2;
    long long xx = k - mid;
    x -= ((xx * (xx + 1)) / 2) + mid - 1;
    if (x < n)
      st = mid + 1;
    else if (x >= n)
      ans = mid, ed = mid - 1;
    else
      return mid;
  }
  return ans;
}
int main() {
  cin >> n >> k;
  if ((k * (k + 1)) / 2 - k + 1 < n) return cout << -1, 0;
  cout << solv();
}
