#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1, -1, -1, 1, 1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  if (n == 1)
    cout << 0;
  else if (n <= k)
    cout << 1;
  else {
    n--;
    long long mx = k * (k - 1) / 2;
    if (n > mx) {
      cout << -1;
      return 0;
    }
    long long l = 1, r = k - 1, mid, res;
    while (l <= r) {
      mid = (l + r) >> 1;
      long long sum = mx - mid * (mid - 1) / 2;
      if (sum > n)
        l = mid + 1;
      else
        res = mid, r = mid - 1;
    }
    long long sum = mx - res * (res - 1) / 2;
    res = k - res;
    if (sum < n) res++;
    cout << res << endl;
  }
  return 0;
}
