#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long sums(long long lo) {
  return (k * (k + 1) / 2 - (lo) * (lo - 1) / 2) - (k - lo);
}
long long check(long long x) { return sums(x) - n; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j;
  cin >> n >> k;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  long long lo = 2, hi = k, mid;
  while (lo < hi) {
    mid = lo + (hi - lo + 1) / 2;
    if (check(mid) >= 0) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  if (sums(2) < n) {
    cout << -1;
    return 0;
  }
  cout << (k - lo + 1);
  return 0;
}
