#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, k;
bool f(ll x) { return ((k + k - x - 1) * x) >> 1LL >= n - 1; }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k;
  ll lo = 0, hi = k, ans = -1;
  while (lo <= hi) {
    ll mid = (lo + hi) >> 1;
    if (f(mid)) {
      ans = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  cout << ans << "\n";
}
