#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
long long eq(long long start, long long k) {
  long long num = k - (start - 1);
  return ((num * (start + k)) / 2) - (num - 1);
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long q = eq(2, k);
  if (n == 1)
    cout << 0 << '\n';
  else if (n <= k)
    cout << 1 << '\n';
  else if (q < n)
    cout << -1 << '\n';
  else {
    long long en = k;
    long long st = 2;
    long long res = -1;
    while (st < en && st > 1) {
      long long mid = st + en >> 1;
      if (eq(mid, k) < n) {
        en = mid;
      } else {
        st = mid + 1;
        res = mid;
      }
    }
    res--;
    cout << k - res << '\n';
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(nullptr), cout.tie(nullptr);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
