#include <bits/stdc++.h>
using namespace std;
long long sum(long long n) { return (n * (n + 1)) / 2; }
long long sum(long long s, long long e) {
  if (s <= 1) {
    return sum(e);
  }
  return sum(e) - sum(s - 1);
}
long long min_s(long long k, long long n) {
  long long start = 1, end = k;
  while (start < end) {
    long long mid = (start + end) / 2;
    long long s = sum(mid, k);
    if (s == n)
      return k - mid + 1;
    else if (s > n)
      start = mid + 1;
    else
      end = mid;
  }
  return k - start + 2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  if (n == 1)
    cout << 0 << '\n';
  else if (n <= k) {
    cout << 1 << '\n';
  } else {
    k--, n--;
    if (sum(k) < n)
      cout << -1 << '\n';
    else
      cout << min_s(k, n) << '\n';
  }
  return 0;
}
