#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, k;
  cin >> n >> k;
  k--;
  ll lo = 0, hi = k + 2;
  while (lo < hi) {
    ll mid = (lo + hi) / 2;
    ll cur = k * mid - (mid * (mid - 1)) / 2;
    if (1 + cur >= n)
      hi = mid;
    else
      lo = mid + 1;
  }
  if (lo > k) lo = -1;
  cout << lo << endl;
  return 0;
}
