#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long tot = k * (k - 1) / 2 + 1;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  if (tot < n) {
    cout << -1;
    return 0;
  }
  tot -= n;
  long long l = 1, r = k - 1;
  while (l < r) {
    long long mid = (l + r) / 2, temp = (mid * (mid + 1)) / 2;
    if (temp > tot)
      r = mid;
    else
      l = mid + 1;
  }
  long long temp = (l * (l + 1)) / 2;
  if (l == tot)
    cout << k - 1 - l;
  else
    cout << k - l;
}
