#include <bits/stdc++.h>
using namespace std;
bool isp(long long n, long long mid, long long temp) {
  long long sum = mid * (mid - 1) / 2;
  if (temp - sum >= n)
    return true;
  else
    return false;
}
int main() {
  long long n, k;
  cin >> n >> k;
  n -= 1;
  long long temp = k * (k - 1) / 2;
  long long ans;
  if (n == 0)
    cout << 0;
  else if (n > temp)
    cout << -1;
  else if (n == temp)
    cout << k - 1;
  else {
    long long low = 1, high = k - 1;
    while (low <= high) {
      long long mid = low + (high - low) / 2;
      if (isp(n, mid, temp)) {
        ans = k - mid;
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
    cout << ans;
  }
  return 0;
}
