#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int dt[] = {0, 1, 0, -1, 0};
const int dtx[] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dty[] = {-1, 1, -1, 0, 1, -1, 0, 1};
const int dtxc[] = {1, 1, 2, 2, -1, -1, -2, -2};
const int dtyc[] = {2, -2, 1, -1, 2, -2, 1, -1};
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
long long n, k, lo, hi, best, ans;
long long f(long long x) { return ((k + k - x + 1LL) * x / 2LL - x + 1LL); }
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  if (n == 1) {
    cout << "0\n";
    return 0;
  }
  if (k * (k + 1) / 2 - (k - 1) < n) {
    cout << "-1\n";
    return 0;
  }
  lo = 1LL;
  hi = k - 1;
  while (lo <= hi) {
    best = (lo + hi) / 2LL;
    long long rs = f(best);
    if (rs >= n) {
      ans = best;
      hi = best - 1;
    } else {
      lo = best + 1;
    }
  }
  cout << ans << '\n';
  return 0;
}
