#include <bits/stdc++.h>
using namespace std;
long long sum(long long l) { return (l * (l + 1)) / 2; }
long long sum(long long l, long long r) {
  if (l <= 1) return sum(r);
  return sum(r) - sum(l - 1);
}
long long minsplits(long long n, long long k) {
  if (sum(k) < n) return -1;
  long long l = 1, r = k;
  while (l < r) {
    long long mid = l + (r - l) / 2;
    long long s = sum(mid, k);
    if (s == n) return k - mid + 1;
    if (s > n)
      l = mid + 1;
    else
      r = mid;
  }
  return k - l + 2;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  if (n == 1)
    cout << "0";
  else if (n <= k)
    cout << "1";
  else {
    --n;
    --k;
    cout << minsplits(n, k);
  }
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long T = 1;
  while (T--) solve();
  return 0;
}
